帮我看下这段代码 关于treemap排序的
我想实现对treemap关键字的倒排序,但排序后的结果是关键字排了,但值全是null了
public static Map sortMapByValue(Map map){
System.out.println("ok1");
// Map mapVK = new TreeMap();
Map mapVK = new TreeMap(new Comparator(){
public int compare(Object o1, Object o2) {
int v1 = ((Integer)o1).intValue();
int v2 = ((Integer)o2).intValue();
int s = v2 - v1;
if(s==0) return -1;
else return s;
}
});
System.out.println("ok2");
Collection col = map.keySet();
Vector v = new Vector(col);
//转置map
for(int i=0;i<v.size();i++){
String key = (String)v.get(i);
Integer value = (Integer)map.get(key);
System.out.println("ok3-" + i + "," +key);
mapVK.put(value,key);
System.out.println("ok>>>>" + (String)mapVK.get(value));
}
return mapVK;
}