How to sort list in reverse order

To sort the elements of the List in the reverse natural order of the strings, get a reverse Comparator from the Collections class with reverseOrder(). Then, pass the reverse Comparator to the sort() method. 
List list = new ArrayList(); 
Comparator comp = Collections.reverseOrder();
Collections.sort(list, comp) 

No comments:

Post a Comment

Please Provide your feedback here