I want to write a comparator that will let me sort a TreeMap by value instead of the default natural ordering.
I tried something like this, but can\'t find out what
In Java 8:
LinkedHashMap sortedMap = map.entrySet().stream(). sorted(Entry.comparingByValue()). collect(Collectors.toMap(Entry::getKey, Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));