/**
* 将集合按照降序排列-Double
* @param nowPartTwoData
* @return
*/
private static List<Map<String,Double>> sortByValueFloatDesc(Map<String, Double> nowPartTwoData) {
List<Map.Entry<String, Double>> lists = new ArrayList<Map.Entry<String, Double>>(nowPartTwoData.entrySet());
Collections.sort(lists, new Comparator<Map.Entry<String, Double>>() {
public int compare(Map.Entry<String, Double> o1, Map.Entry<String, Double> o2) {
Double q1 = Double.parseDouble(o1.getValue()+"");
Double q2 = Double.parseDouble(o2.getValue()+"");
Double p = q2 - q1;
if (p > 0) {
return 1;
} else if (p == 0) {
return 0;
} else
return -1;
}
});
for (Map.Entry<String, Double> set : lists) {
System.out.println(set.getKey() + " " + set.getValue());
}
return null;
}

相关文章:

  • 2021-08-27
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-21
  • 2022-02-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2021-11-09
  • 2022-12-23
相关资源
相似解决方案