Java Collection Framework provides a convenient reverse comparator, to
sort List of objects in reverse order. You can obtain reverse Comparator, by
calling Collections.reverseOrder(), which by
default sort List of Integer in reverse
numeric order and List of String in reverse alphabetic order. It
actually reverse natural ordering of objects imposed by Comparable interface. Apart from this method, Collections class also
provides an overloaded method Collections.reverseOrder(Comparator
cmp), which takes a Comparator,
and sort List on reverse order of that Comparator. So next time if you need to sort
your Collection in reverse order, you don’t need to write any extra comparator
by yourself, you can directly leverage reverse comparator provided by java.util.Collections class. It is as simple as calling Collections.sort() method providing comparator wrapped into Collections.reverseOrder() method. By
using these two methods, you can sort any List
implementation e.g. ArrayList,
LinkedList
or Vector
in Java.

Java Program to sort ArrayList in reverse Order

Here is complete code for sorting List in reverse order in Java. In this
program we have two list, List<Integer> and List<String> and we are
sorting them first in natural order and than in there reverse order by using Collections.reverseOrder() method.

importjava.util.ArrayList;

importjava.util.Arrays;

importjava.util.Collections;

importjava.util.List;

importorg.slf4j.Logger;

importorg.slf4j.LoggerFactory;

/**

* Java Program to sort List of object in
reverse order. We will see examples of

* sorting Array List in reverse order of both
default ordering as well as any

That's all on How to sort List of Strings or Integers in to revrese
order. You can also use same technique to sort any List into reverse order
of there natural ordering or custom ordering imposed by any Comparator in Java.

Other Java Collection tutorials you may like
How to sort a Map by keys and values in Java? (tutorial)
How to sort an ArrayList in ascending and descending order in Java? (tutorial)
Difference between ArrayList and HashSet in Java? (answer)
The difference between TreeMap and TreeSet in Java? (answer)
The difference between HashMap and ConcurrentHashMap in Java? (answer)
The difference between HashSet and TreeSet in Java? (answer)
The difference between ArrayList and LinkedList in Java? (answer)
The difference between Vector and ArrayList in Java? (answer)

Thanks for reading this article so far. If you like this article then please share with your friends and colleagues. If you have any question or feedback then please drop a comment.