Collections.sort(testList);
Collections.reverse(testList);
That will do what you want. Remember to import Collections though!
Here is the documentation for Collections.
W3Schools
w3schools.com › Java › java_sort_list.asp
Java Sort a List - List Sorting
Sort a Java list alphabetically or numerically with Collections.sort().
Top answer 1 of 16
696
Collections.sort(testList);
Collections.reverse(testList);
That will do what you want. Remember to import Collections though!
Here is the documentation for Collections.
2 of 16
184
Descending:
Collections.sort(mArrayList, new Comparator<CustomData>() {
@Override
public int compare(CustomData lhs, CustomData rhs) {
// -1 - less than, 1 - greater than, 0 - equal, all inversed for descending
return lhs.customInt > rhs.customInt ? -1 : (lhs.customInt < rhs.customInt) ? 1 : 0;
}
});
Sorting of List Using Stream API in Java8| An Important ...
07:34
Sort list of objects in ascending & descending order in java using ...
12:21
List Sorting In Java | Java Full Course From Scratch - YouTube
01:00
How can you sort a Collection? #javalanguage #javacoding #javatips ...
Java Programming Series Episode 28: Using Collections.sort ...
03:43
Java 8 Stream Program to Sort the List of Strings in Ascending ...
Medium
medium.com › @AlexanderObregon › sorting-lists-in-java-using-collections-sort-14b150ac8682
Sorting Lists in Java Using Collections.sort | Medium
June 4, 2025 - Sorting is a basic task in any programming language, but the way it’s done can reveal a lot about how things work behind the scenes. Java provides several tools for sorting, but one of the most commonly used is Collections.sort(). It works with lists of numbers, strings, or even custom objects when you provide it with a way to compare them.
GeeksforGeeks
geeksforgeeks.org › java › collections-sort-java-examples
Collections.sort() in Java with Examples - GeeksforGeeks
The Collections.sort() method in Java is used to sort elements of a List in ascending order. It is part of the java.util.Collections class and works with List implementations like ArrayList and LinkedList.
Published: April 30, 2026
Sentry
sentry.io › sentry answers › java › how to sort a list in java?
Sort a List in Java Using Collections, Comparator, or Stream | Sentry
3 weeks ago - If you want to change the ordering of your sort, use the overloaded sort(List<T> list, Comparator<? super T> c) method and provide a comparator: import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; public class Example { public static void main(String[] args) { List<Integer> test = new ArrayList<>(Arrays.asList(8, 6, 3, 7, 2)); Collections.sort(test, Comparator.reverseOrder()); for (Integer i : test) { System.out.print(i); } } }
CodeJava
codejava.net › java-core › collections › sorting-list-collections-examples
Java Sort List Collections Examples
[Master REST API Development and Java and Spring Boot] In Java, it’s pretty easy to sort elements in a list collection using the Collections.sort() static utility method.
Codecademy
codecademy.com › docs › java › arraylist › .sort()
Java | ArrayList | .sort() | Codecademy
January 5, 2024 - Used to sort arrays of primitive types and objects.
Baeldung
baeldung.com › home › java › java collections › sorting in java
Sorting in Java | Baeldung
February 3, 2026 - Java 8 comes with two new APIs useful for sorting – comparing() and thenComparing() in the Comparator interface. These are quite handy for the chaining of multiple conditions of the Comparator. Let’s consider a scenario where we may want to compare Employee by age and then by name: @Test public void givenArrayObjects_whenUsingComparing_thenSortedArrayObjects() { List<Employee> employeesList = Arrays.asList(employees); employees.sort(Comparator.comparing(Employee::getAge)); assertTrue(Arrays.toString(employees.toArray()) .equals(sortedArrayString)); }