Sort List in reverse in order

后端 未结 8 702
别那么骄傲
别那么骄傲 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:38

    Use this:

    Collections.reverse(list);
    
    0 讨论(0)
  • 2020-11-29 09:50

    How I would do it is:

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

    And happy coding :)

    0 讨论(0)
提交回复
热议问题