java集合中根据对象的属性值进行排序
列入想排序 List<GaService> list 可以根据对象里面的属性进行排序//signatureDate是GaService里面的一个属性//正序排序 调用sort方法Comparator<GaService> comparing = Comparator.comparing(temp -> temp.getSignatureDate();list.sort
·
列入想排序 List<GaService> list 可以根据对象里面的属性进行排序
//signatureDate是GaService里面的一个属性
//正序排序 调用sort方法
Comparator<GaService> comparing = Comparator.comparing(temp -> temp.getSignatureDate();
list.sort(comparing);
//倒序排序
List<GaService> collect = list.stream().sorted(
Comparator.comparing(temp::getSignatureDate).reversed()
).collect(Collectors.toList());
更多推荐
已为社区贡献1条内容
所有评论(0)