I have seen similar questions but still don't quite understand how to do this.
public static Object[] dbSort(Object[] a){
Arrays.sort(a);
return a;
}
when given an object array that can contain either just numbers or just strings or both how can I sort it so numbers-> smallest to biggest, strings sorted according to the alphabet, and if both then numbers sorted first and then strings.
in the code above it only works if it is a integers in the object array otherwise it gives an error since it can't sort strings as well(i think).
here are some examples to make it more clear about what I want.
given {6, 2, 3, 4, 5} should return {2, 3, 4, 5, 6}},
given {14, 32, 3, 5, 5} should return {3, 5, 5, 14, 32}},
given {1, 2, 3, 4, 5} should return {1, 2, 3, 4, 5}
given {"Banana", "Orange", "Apple", "Mango", 0, 2, 2} should return {0, 2, 2, "Apple", "Banana", "Mango", "Orange"}}
given {"C", "W", "W", "W", 1, 2, 0} should return {0,1,2,"C","W","W","W"}