Null项目参与排序

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

Copyright © 2024 wzhw2015
Powered by .NET 8.0 on Kubernetes