@Test public void testSortByValueAscending() { Map<String, Integer> testMap = new LinkedHashMap<>(1000); for (int i = 999; i >= 0; i--) { testMap.put("test" + i, i); } testMap = MapUtils.sortByValueAscending(testMap); Assert.assertEquals(1000, testMap.size()); Integer previous = null; for (Map.Entry<String, Integer> entry : testMap.entrySet()) { Assert.assertNotNull(entry.getValue()); if (previous != null) { Assert.assertTrue(entry.getValue() >= previous); } previous = entry.getValue(); } }
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValueAscending(Map<K, V> map) { return sortByValue(map, (o1, o2) -> o1.getValue().compareTo(o2.getValue())); }
MapUtils { public static <K, V extends Comparable<? super V>> Map<K, V> sortByValueAscending(Map<K, V> map) { return sortByValue(map, (o1, o2) -> o1.getValue().compareTo(o2.getValue())); } }
MapUtils { public static <K, V extends Comparable<? super V>> Map<K, V> sortByValueAscending(Map<K, V> map) { return sortByValue(map, (o1, o2) -> o1.getValue().compareTo(o2.getValue())); }  }
MapUtils { public static <K, V extends Comparable<? super V>> Map<K, V> sortByValueAscending(Map<K, V> map) { return sortByValue(map, (o1, o2) -> o1.getValue().compareTo(o2.getValue())); }  static Map<K, V> sortByValueAscending(Map<K, V> map); static Map<K, V> sortByValueDescending(Map<K, V> map); }
MapUtils { public static <K, V extends Comparable<? super V>> Map<K, V> sortByValueAscending(Map<K, V> map) { return sortByValue(map, (o1, o2) -> o1.getValue().compareTo(o2.getValue())); }  static Map<K, V> sortByValueAscending(Map<K, V> map); static Map<K, V> sortByValueDescending(Map<K, V> map);  }