Map<String, Double> content = new HashMap<>();
//根据map的值排序
content.entrySet().stream().sorted(Map.Entry.comparingByValue()).forEach(single -> {
content.put(single.getKey(), single.getValue());
});
此外 ,Map.entry还提供根据键值排序的自定义比较器排序:

Map<String, Double> content = new HashMap<>();
//根据map的值排序
content.entrySet().stream().sorted(Map.Entry.comparingByValue()).forEach(single -> {
content.put(single.getKey(), single.getValue());
});
此外 ,Map.entry还提供根据键值排序的自定义比较器排序:


被折叠的 条评论
为什么被折叠?