HashMap<Character, Integer> map = new HashMap<>();
map.put('a',325);
map.put('b',32);
- 仅对value进行排序(不要key)
ArrayList<Integer> list = new ArrayList<>(a.values());
Collections.sort(list);
- 对value进行排序(要key)
ArrayList<Map.Entry<Character, Integer>> list = new ArrayList(map.entrySet());
Collections.sort(list, (a, b)-> {
return b.getValue() - a.getValue() ;
});