java集合中根据对象的属性值进行排序

java集合中根据对象的属性值进行排序,第1张

列入想排序 List list 可以根据对象里面的属性进行排序

//signatureDate是GaService里面的一个属性

//正序排序 调用sort方法

Comparator comparing = Comparator.comparing(temp -> temp.getSignatureDate();

        list.sort(comparing);

//倒序排序

List collect = list.stream().sorted(

        Comparator.comparing(temp::getSignatureDate).reversed()

).collect(Collectors.toList());

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/905486.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-15
下一篇2022-05-15

发表评论

登录后才能评论

评论列表(0条)

    保存