/**
* map根据value 倒序排
*
* @param map
* @return
*/
private List<String> sortMap (Map<String, Integer> map) {
List<Map.Entry<String, Integer>> list = new ArrayList<>(map.entrySet());
Collections.sort(list, new Comparator<Map.Entry<String, Integer>>() {
@Override
public int compare (Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
//此处为倒序 升序将o1和o2调换位置
return o2.getValue() - o1.getValue();
}
});
List<String> productList = new ArrayList<>();
for (Map.Entry s : list) {
productList.add(String.valueOf(s.getKey()));
}
return productList;
}