hashMap<int ,String[] > 根据map的value值排序.
hashmap<int,String[]>如题.比如String[]str={"12","123","","akjsdflaj","排序"}String[]str={"1...
hashmap<int,String[]> 如题.比如String[] str={"12","123","","akjsdflaj","排序"}String[] str={"12","123","","akjsdflaj","排序"}String[] str={"12","124","","akjsdflaj","排序"}有N 条这样的数据..根据String数据里的第二个下标排序.求解.. 能给代码是最好...
展开
1个回答
2013-05-08
展开全部
HashMap<String, Integer> UserMap=new HashMap<String ,Integer>(100);
for (Iterator iter = UserInfo.keySet().iterator(); iter.hasNext();) {//遍历所有人,把人气数据放到一个新的表中
sTUID =(String) iter.next();
User = (String[])UserInfo.get(sTUID);
sUserName=User[1]+User[7];
iMyReputation=(Integer.parseInt(User[2]));
UserMap.put(T.UserNameLink(sTUID, sUserName), iMyReputation);
}
Map<String, Integer> sortMap = new MapSort().sortMap(UserMap);//新表排序
for (Iterator iter = sortMap.keySet().iterator(); iter.hasNext();) {//遍历,显示出来
sTUID =(String) iter.next();
retStr+=sTUID+sortMap.get(sTUID)+"点<br/>";
iNums++;
if(iNums>20)
break;
}
for (Iterator iter = UserInfo.keySet().iterator(); iter.hasNext();) {//遍历所有人,把人气数据放到一个新的表中
sTUID =(String) iter.next();
User = (String[])UserInfo.get(sTUID);
sUserName=User[1]+User[7];
iMyReputation=(Integer.parseInt(User[2]));
UserMap.put(T.UserNameLink(sTUID, sUserName), iMyReputation);
}
Map<String, Integer> sortMap = new MapSort().sortMap(UserMap);//新表排序
for (Iterator iter = sortMap.keySet().iterator(); iter.hasNext();) {//遍历,显示出来
sTUID =(String) iter.next();
retStr+=sTUID+sortMap.get(sTUID)+"点<br/>";
iNums++;
if(iNums>20)
break;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询