//map转List
private List<CityForQmi> mapTransitionList(Map<String, CityForQmi> map) {
List<CityForQmi> list = new ArrayList<>();
Iterator item = map.entrySet().iterator(); // 获得map的Iterator
while (item.hasNext()) {
Entry<String, CityForQmi> entry = (Entry) item.next();
list.add(entry.getValue());
}
return list;
}
//Map降序排序
private <K, V extends Comparable<? super V>> Map<K, V> sortByValueDescending(Map<K, V> map)
{
List<Map.Entry<K, V>> list = new LinkedList<>(map.entrySet());
Collections.sort(list, (o1, o2) -> {
int compare = (o1.getValue()).compareTo(o2.getValue());
return -compare;
});
Map<K, V> result = new LinkedHashMap<>();
for (Map.Entry<K, V> entry : list) {
result.put(entry.getKey(), entry.getValue());
}
return result;
}