java Collection 排序

Integer排序

Collections.sort(resList, Comparator.comparingInt(SpecialStateCountVo::getSpecialNum).reversed());

String排序
list= list.stream()
.sorted(
Comparator.comparing(MajorDangerCntVO::getRegionCode)
.thenComparing(MajorDangerCntVO::getLv))
.collect(Collectors.toList());
String 转int 排序
Collections.sort(industryCountVOList,
(o1, o2) ->
Integer.valueOf(o2.getCnt())
.compareTo(Integer.valueOf(o1.getCnt()))
);

Double 排序
majorDangerRegionCntVOList=majorDangerRegionCntVOList.stream()
.sorted(Comparator.comparingDouble(MajorDangerRegionCntVO::getTotalCount).reversed())
.collect(Collectors.toList());

posted @ 2022-12-07 00:09  赵钱富贵  阅读(170)  评论(0编辑  收藏  举报