January 2014
Intermediate to advanced
736 pages
70h 43m
English
Method sort sorts the elements of a List, which must implement the Comparable interface. The order is determined by the natural order of the elements’ type as implemented by a compareTo method. Method compareTo is declared in interface Comparable and is sometimes called the natural comparison method. The sort call may specify as a second argument a Comparator object that determines an alternative ordering of the elements.
If list is a List of Comparable objects (such as Strings), you can use Collections method sort to order the elements in ascending order as follows:
Collections.sort( list ); // sort list into ascending order
You can sort the List in ...
Read now
Unlock full access