About 335,000 results
Open links in new tab
  1. sorting - Reverse a comparator in Java 8 - Stack Overflow

    Oct 7, 2015 · If you want to reverse the ordering of an existing comparator, you can use Comparator.reversed(). Sample code: .sorted(Comparator.reverseOrder()); . // stream is now …

  2. Comparator reversed() method in Java with examples

    Feb 5, 2021 · The reversed() method of Comparator Interface in Java returns a comparator that imposes the reverse ordering of this comparator. If you use sort method of the array and …

  3. Comparator reverseOrder() method in Java with examples

    Apr 12, 2023 · The reverseOrder() method of Comparator Interface in Java returns a comparator that use to compare Comparable objects in reverse of natural order. The returned comparator …

  4. Best way of creating a Comparator that reverses order

    Jun 25, 2014 · Using a comparator would be the correct approach here in order to avoid the overhead of reversing an array. If the classes you are comparing implement Comparable you …

  5. How to sort an array of ints using a custom comparator?

    Sep 13, 2010 · I need to sort an array of ints using a custom comparator, but Java's library doesn't provide a sort function for ints with comparators (comparators can be used only with …

  6. Collections.reverseOrder () in Java with Examples

    Jan 10, 2023 · The reverseOrder() method of Comparator Interface in Java returns a comparator that use to compare Comparable objects in reverse of natural order. The returned comparator …

  7. Java 8 Comparator Comparing Reverse Order

    Dec 7, 2021 · In this tutorial, We'll learn how to use a comparator to sort the collection in reverse order. In Java 8, Comparator interface is added with the reverse () method to reverse the …

  8. Java’s Comparator.reverseOrder () Method Explained - Medium

    Jan 25, 2025 · The Comparator.reverseOrder() method in the java.util.Comparator class is a simple and effective tool for creating a comparator that sorts input in reverse (descending) …

  9. Reverse Order Comparators in Java - Techie Delight

    May 1, 2021 · We can use static Comparator.reverseOrder() that returns a comparator that compares objects in reverse order. It imposes the reverse of the natural ordering. Usage: The …

  10. Java Sort Arrays Examples (with Comparable and Comparator)

    Apr 14, 2021 · 4. Sorting an array into reverse order. To sort an array of objects into the reverse of natural ordering of its elements, we can use this syntax: Arrays.sort(array, …

  11. Some results have been removed
Refresh