//对string类型的list排序
List<String> collectsort =
collectByHz.keySet().stream().sorted(Comparator.comparing(Integer::new)).collect(Collectors.toList());
//对对象的某个元素排序(加上.reversed()为倒序)
List<EconomyUserView> collectItem =
views.stream().sorted(Comparator.comparing(EconomyUserView::getRelation)).collect(Collectors.toList());
使用stream对list的对象和string排序
最新推荐文章于 2023-10-17 10:31:43 发布