1、对Key进行排序
Map<Double, List<CValuePerformance>> cValueMap = q.stream().collect(Collectors.groupingBy(CValuePerformance::getTotalCvalue, Collectors.toList()))
.entrySet().stream().sorted(Map.Entry.<Double,List<CValuePerformance>>comparingByKey().reversed()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new));
2、对值进行排序
LinkedHashMap<Double, String> collect = nn.entrySet().stream().sorted(Map.Entry.<Double, String>comparingByValue().reversed()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, LinkedHashMap::new));
注意:要有顺序需要生成 LinkedHashMap 链表结构的