Null项目参与排序

Posted on 2020-02-26 22:36  wzhw2015  阅读(168)  评论(0)    收藏  举报
1.item1升序,item2升序,item3(存在NULL项目,NULL项目排在后面)升序
  Collections.sort(list, Comparator.comparing(Bean::getItem1)
                                   .thenComparing(Bean::getItem2)
                                   .thenComparing(Bean::getItem3, Comparator.nullsLast(Comparator.naturalOrder())));

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3