Returns a comparator that imposes the reverse of the natural
ordering on a collection of objects that implement the
Comparable
interface. (The natural ordering is the ordering
imposed by the objects' own compareTo
method.) This enables a
simple idiom for sorting (or maintaining) collections (or arrays) of
objects that implement the Comparable
interface in
reverse-natural-order. For example, suppose a
is an array of
strings. Then:
Arrays.sort(a, Collections.reverseOrder());sorts the array in reverse-lexicographic (alphabetical) order.
The returned comparator is serializable.
<T> | the class of the objects compared by the comparator |
Comparable
interface.
Comparable
Diagram: Collections