To sort in descending order, pass a reversing Comparator to sorted(), such as Comparator.reverseOrder() or Collections.reverseOrder().
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
public class SortDescending {
public static void main(String[] args) {
List<Integer> list = Arrays.asList(10, 15, 8, 49, 25, 98, 98, 32, 15);
List<Integer> desc = list.stream()
.sorted(Comparator.reverseOrder())
.collect(Collectors.toList());
System.out.println(desc);
// Same result with an explicit, overflow-safe comparator
List<Integer> desc2 = list.stream()
.sorted((a, b) -> Integer.compare(b, a))
.collect(Collectors.toList());
System.out.println(desc2);
}
}[98, 98, 49, 32, 25, 15, 15, 10, 8]
[98, 98, 49, 32, 25, 15, 15, 10, 8]
If asked for the top 3 values, combine this with limit: sorted(Comparator.reverseOrder()).limit(3). Adding distinct() first gives the top 3 unique values.
A concise interview answer is
I pass a reversing comparator: stream().sorted(Comparator.reverseOrder()). For objects I use Comparator.comparing(...).reversed(), and I avoid (a, b) -> b - a because subtraction can overflow.
Last updated: 11 November 2026
Previous question: Given a list of integers, sort the values using streams.
Next question: Contains Duplicate: return true if any value appears at least twice in an integer array.