可能重复:
TreeMap 按值排序
嗨,我想按值而不是键对 TreeMap 集合进行排序。例如,
TreeMap map=new TreeMap();
map.put(new Integer(100),"ccc");
map.put(new Integer(300),"bbb");
map.put(new Integer(200),"ddd");
map.put(new Integer(400),"aaa");
它应该被订购为,
1) 400 -> aaa
2) 300 -> bbb
3) 100 -> ccc
4) 200 -> ddd