java对象排序

  List<QuestionChooseVO> voList = Lists.newArrayList();
......
在voList中插入一系列QuestionChooseVO对象

1、 voList.sort((QuestionChooseVO h1, QuestionChooseVO h2) -> h1.getOrderNum().compareTo(h2.getOrderNum()));
2、
List integers = Arrays.asList(1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 9, 0);
倒序:
List collect = integers.stream().sorted(Comparator.comparing(Integer::intValue).reversed()).collect(Collectors.toList());
3、 List collect2 = integers.stream().sorted((p1, p2) ->p2-p1).collect(Collectors.toList());
4、List collect1 = integers.stream().sorted((p1, p2) -> p2.compareTo(p1)).collect(Collectors.toList());

剩余几个常用:
1、List collect3 = list.stream().map(Student::getId).collect(Collectors.toList());
2、 Map<Long, Student> collect4 = list.stream().collect(Collectors.toMap(Student::getId, t1 -> t1, (k1, k2) -> k1));
3、 Map<Long, List> collect5 = list.stream().collect(Collectors.groupingBy(Student::getId));
4、List schoolClassesVos = reportService.getClassListByLessonId(lessonId);
List collect6 = list.stream().filter(st -> st.getId() >= 2l).collect(Collectors.toList());

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值