private Map<Long, Double> sortHotTopic(Map<Long, Double> map) {
Map<Long,Double> result = new LinkedHashMap<Long,Double>();
List<Map.Entry<Long,Double>> list = new LinkedList<Map.Entry<Long,Double>>(map.entrySet());
Collections.sort(list,new Comparator<Map.Entry<Long,Double>>() {
//值降序排
public int compare(Entry<Long,Double> o1,
Entry<Long,Double> o2) {
return o2.getValue().compareTo(o1.getValue());
}
});
for(Map.Entry<Long,Double> mapping : list){
result.put(mapping.getKey(), mapping.getValue());
}
return result;
}
Map值排序
最新推荐文章于 2024-05-30 08:34:38 发布