/** * 将集合按照降序排列-Double * @param nowPartTwoData * @return */private static List> sortByValueFloatDesc(Map nowPartTwoData) { List> lists = new ArrayList>(nowPartTwoData.entrySet()); Collections.sort(lists, new Comparator>() { public int compare(Map.Entry o1, Map.Entry 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 set : lists) { System.out.println(set.getKey() + " " + set.getValue()); } return null;}
Original: https://www.cnblogs.com/gjths/p/12785427.html
Author: ExpectoPatronum—S
Title: 根据Map值 double 类型的进行排序
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/608587/
转载文章受原作者版权保护。转载请注明原作者出处!