更新时间:2023-01-30 14:53:23
自Java 1.8
java.util.Comparator.reversed()
Since Java 1.8 java.util.Comparator.reversed()
myMap.entrySet().stream()
.sorted(Map.Entry.comparingByValue().reversed())
.collect(Collectors.toMap(Entry::getKey, Entry::getValue));