Sort List in reverse in order

后端 未结 8 740
别那么骄傲
别那么骄傲 2020-11-29 09:03

I have List list1 in direct order. List list = Ordering.natural().sortedCopy(asu2);

How to change order. And I don\'t know how to rewrite

8条回答
  •  半阙折子戏
    2020-11-29 09:50

    How I would do it is:

    personsList.sort(Comparator.comparing(Person::getAge, Comparator.reverseOrder()));
    

    And happy coding :)

提交回复
热议问题