1.錯誤使用方法java
List<User> collect = list.stream().sorted(Comparator
.comparing(User::getScoreA).reversed()
.thenComparing(User::getScoreB).reversed()
).collect(Collectors.toList());
2.正確使用方法linux
List<User> collect = list.stream().sorted(Comparator
.comparing(User::getScoreA)
.thenComparing(User::getScoreB).reversed()
).collect(Collectors.toList());
3.推薦使用方法android
List<User> collect = list.stream().sorted(Comparator .comparing(User::getScoreA) .thenComparing((User u)->-u.getScoreB()) ).collect(Collectors.toList());