Java8は、Mapが1行の値でソートされていることを認識します

List<Map.Entry<Integer,Integer>>list = map.entrySet().stream()
      .sorted((entry1, entry2) -> entry1.getValue().compareTo(entry2.getValue()))
      .collect(Collectors.toList());

値型は整数であり、他の型も同様であると想定されています。

 

おすすめ

転載: blog.csdn.net/qq_28411869/article/details/85792509