Sort the ArrayList in descending order

In the previous post, we have seen how to sort the arrayList. In this post, we will see how to sort the arrayList in descending order.

We will use the method Collections.reverseOrder() to sort the arrayList in reverse order.


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

arraylist: This is the arrayList which needs to be sorted.

Collections.reverseOrder(): This method is used for sorting in reverse order.



List of integer before sorting : [4, 2, 6, 1] List of integer after sorting : [6, 4, 2, 1]
Print Friendly, PDF & Email
Sort ArrayList in java
Sort ArrayList of Objects using Comparable and Comparator interface
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of He is an automation engineer having more than 8 years of experience who loves troubleshooting in automation and finding innovative ways to solve the problems. His other leisurely activities includes playing harmonica, paintings, sketching portrait, watching movies and travelling etc.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *