问候,
我有 2 个对象:
请愿
签字人(签字人)
我写了这段代码:
public List<Petition> getTheMostSigned(long groupId){
List<Petition> petitionList = petitionPersistence.findByStatusAndGroupId(0,groupId);
_log.info("list avant getTheMostSigned size : "+petitionList.stream().map(petition -> petition.getSignataires().size()).collect(Collectors.toList()));
List<Petition> resultList = petitionList.stream()
.sorted(Comparator.comparingInt(petition -> petition.getSignataires().size()))
.sorted(Collections.reverseOrder())
.collect(Collectors.toList());
_log.info("list apres getTheMostSigned size : "+resultList.stream().map(petition -> petition.getSignataires().size()).collect(Collectors.toList()));
return resultList;
getSignaaires() 返回一个列表。
但结果并不是我所期望的:
2018-09-12 12:44:25.686 INFO [http-nio-8080-exec-10][PetitionLocalServiceImpl:390] list avant getTheMostSigned size : [0, 0, 400, 0, 3, 401, 5501]
2018-09-12 12:44:25.856 INFO [http-nio-8080-exec-10][PetitionLocalServiceImpl:396] list apres getTheMostSigned size : [5501, 401, 3, 0, 0, **400**, 0]
如您所见,倒数第二个不是好的。你知道为什么比较器不做这项工作吗?
慕莱坞森
一只名叫tom的猫
HUWWW
相关分类