java8 list多条件倒序排序, 根据对象内的某个条件去重

需求:lambda根据多个条件对list进行排序,并且根据对象内的某个属性值来去重

 resList = resList.stream()
                        .sorted(Comparator.comparing(ResCenterAuditDTO::getCreateTime).reversed())
                        .sorted(Comparator.comparing(ResCenterAuditDTO::getMatchRate).reversed())
                        .collect(Collectors
                                .collectingAndThen(Collectors
                                        .toCollection(() -> new TreeSet<>(Comparator
                                                .comparing(ResCenterAuditDTO::getAuditId))), ArrayList::new)
                        );

版权声明:本文为weixin_43748936原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。