排序比较器的方法

使用lambda表达式

Collections.sort(List, (a,b) ->  x1 - x2);

自定义Comparator方法

Collections.sort(List, new Comparator<E>(){
    public int compare(int a, int b){
      return a - b;
    }
});

posted @ 2021-07-03 20:43  acchris  阅读(55)  评论(0)    收藏  举报