How to sort an ArrayList in Descending Order in Java Last Updated : 11 Dec, 2018 Comments Improve Suggest changes Like Article Like Report Given an unsorted ArrayList, the task is to sort this ArrayList in descending order in Java. Examples: Input: Unsorted ArrayList: [Geeks, For, ForGeeks, GeeksForGeeks, A computer portal] Output: Sorted ArrayList: [GeeksForGeeks, Geeks, ForGeeks, For, A computer portal] Input: Unsorted ArrayList: [Geeks, For, ForGeeks] Output: Sorted ArrayList: [Geeks, ForGeeks, For] Approach: An ArrayList can be Sorted by using the sort() method of the Collections Class in Java. This sort() method takes the collection to be sorted and Collections.reverseOrder() as the parameter and returns a Collection sorted in the Descending Order. Collections.reverseOrder() acts as the comparator in this method. Syntax: Collections.sort(ArrayList, Collections.reverseOrder()); Below is the implementation of the above approach: Java // Java program to demonstrate // How to sort ArrayList in descending order import java.util.*; public class GFG { public static void main(String args[]) { // Get the ArrayList ArrayList<String> list = new ArrayList<String>(); // Populate the ArrayList list.add("Geeks"); list.add("For"); list.add("ForGeeks"); list.add("GeeksForGeeks"); list.add("A computer portal"); // Print the unsorted ArrayList System.out.println("Unsorted ArrayList: " + list); // Sorting ArrayList in descending Order // using Collection.sort() method // by passing Collections.reverseOrder() as comparator Collections.sort(list, Collections.reverseOrder()); // Print the sorted ArrayList System.out.println("Sorted ArrayList " + "in Descending order : " + list); } } Output: Unsorted ArrayList: [Geeks, For, ForGeeks, GeeksForGeeks, A computer portal] Sorted ArrayList in Descending order : [GeeksForGeeks, Geeks, ForGeeks, For, A computer portal] Comment More infoAdvertise with us Next Article How to sort an ArrayList in Descending Order in Java R RishabhPrabhu Follow Improve Article Tags : Java Practice Tags : Java Similar Reads How to sort an ArrayList in Ascending Order in Java Given an unsorted ArrayList, the task is to sort this ArrayList in ascending order in Java. Examples: Input: Unsorted ArrayList: [Geeks, For, ForGeeks, GeeksForGeeks, A computer portal] Output: Sorted ArrayList: [A computer portal, For, ForGeeks, Geeks, GeeksForGeeks] Input: Unsorted ArrayList: [Gee 2 min read Java Program to Sort an ArrayList ArrayList is the class provided in the Collection framework. In Java, the collection framework is defined in java.util package. ArrayList is used to dynamically stores the elements. It is more flexible than an array because there is no size limit in ArrayList. ArrayList stores the data in an unorder 6 min read How to sort an Array of Strings in Java Array Of StringsTo sort an array of strings in Java, we can use Arrays.sort() function. Java // A sample Java program to // sort an array of strings // in ascending and descending // orders using Arrays.sort(). import java.util.Arrays; import java.util.Collections; // Driver Class public class SortE 3 min read How to create a TreeMap in reverse order in Java By default TreeMap elements in Java are sorted in ascending order of keys. However, we can create the TreeMap in reverse order using Collections.reverseOrder() method in Java and display the elements in descending order of keys. The Collections.reverseOrderS() method in Java returns a Comparator tha 2 min read Get first and last elements from ArrayList in Java Given an array list, find the first and last elements of it. Examples: Input : aList = {10, 30, 20, 14, 2} Output : First = 10, Last = 2 Input : aList = {10, 30, 40, 50, 60} Output : First = 10, Last = 60 The last element is at index, size - 1 and the first element is stored at index 0. If we know h 3 min read Like