【发布时间】:2012-12-19 01:39:36
【问题描述】:
您好,我想按值而不是键对 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
【问题讨论】:
-
使用这些值作为键有什么问题?为什么要强制它们作为值