Sort List in reverse in order

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

    you can reverse any type by just putting "-" or negative sign infront of your return.

    Collections.sort(listed, new Comparator() {
    
        @Override
        public int compare(Object o1, Object o2) {
    
            return -o1.getLeft().compareTo(o2.getLeft());
    
        }
    });
    
        

    提交回复
    热议问题