In alphabetical order, I assume that the order should be: A | a <B | b <C | C ... I hope this is what @Nick (or was) looking for, and the answer follows the above assumption.
I would suggest using the class comparison method for the Comparator interface class:
public int compare(Object o1, Object o2) { return o1.toString().compareToIgnoreCase(o2.toString()); }
and from the calling method, the Arrays.sort method with the custom Comparator is called as:
Arrays.sort(inputArray, customComparator);
Observed results: input array: “Vani”, “Kali”, “Mohan”, “Sony”, “Kuldep”, “Arun”
conclusion (in alphabetical order): Arun, Kali, cooldep, Mohan, Sony, Vani
Conclusion (Natural order by executing Array.sort (inputArray) array: Arun, Kali, Mohan, Sony, Vani, Kuldep
Thus, in the case of natural ordering, [Vani <kuldeep], which, to my understanding of the alphabetical order, is not desirable.
for a better understanding of the natural and alphabetic / lexical order, visit the discussion here