Map<Long, List<EconomyUserView>> collect1= economyUserViewList.stream().collect(Collectors.groupingBy(EconomyUserView::getOrgId));
//根据户主顺序排序
Map<Long, List<EconomyUserView>> collectByGroupUser = new HashMap<>();
for (Long item : collect1.keySet()){
List<EconomyUserView> views = collect1.get(item);
//排序操作(顺序排)在getrelation()后面加.reversed()等于倒序
List<EconomyUserView> collect = views.stream().sorted(Comparator.comparing(EconomyUserView::getRelation)).collect(Collectors.toList());
collectByGroupUser.put(item,collect);
}
使用流排序
最新推荐文章于 2023-05-25 10:52:36 发布