Example & Tutorial understanding programming in easy ways.

How to sort list in reverse order?

To sort the elements of the List in the reverse natural order of the Strings java provides a static method of in collection interface called reverseOrder() which returns reverse Comparator from the Collections class. Then, pass the reverse Comparator to the sort() method.

List list = new ArrayList();
Comparator revList= Collections.reverseOrder();
Collections.sort(list, revList);

Read More →