collections - reversing their order


■ Any List can be reversed by simply calling Collections.reverse( listname );


■ To reverse a Set or an Array you use the form of the appropriate sort(..) method that lets you specify a Comparator to be used.   In the sort(obj, comparator) method you specify Collections.reverseOrder( ) which provides a reverse comparator.  i.e


Arrays.sort(anarray, Collections.reverseOrder( ));           or

Collections.sort(list, Collections.reverseOrder( ));