1 /** 2 * 将集合按照降序排列-FLOAT 3 * @param nowPartTwoData 4 * @return 5 */ 6 private static List<Map.Entry<String,Float>> sortByValueFloatDesc(Map<String, Float> nowPartTwoData){ 7 //这里将map.entrySet()转换成list 8 List<Map.Entry<String,Float>> list = new ArrayList<Map.Entry<String,Float>>(nowPartTwoData.entrySet()); 9 //然后通过比较器来实现排序 10 Collections.sort(list,new Comparator<Map.Entry<String,Float>>() { 11 //降序排序 12 @Override 13 public int compare(Map.Entry<String, Float> o1, 14 Map.Entry<String, Float> o2) { 15 return o2.getValue().compareTo(o1.getValue()); 16 } 17 }); 18 19 return list; 20 }