Sort List in reverse in order
Use this:
Collections.reverse(list);
There is a method reverseOrder
in the Collections
class which returns a Comparator
.
You can use it like Collections.sort(list, Collections.reverseOrder());
How I would do it is:
personsList.sort(Comparator.comparing(Person::getAge, Comparator.reverseOrder()));
And happy coding :)