How can I sort a LinkedHashMap<String, Integer>
based on its values?.
I need to sort it based on the values which are Integer
s.
This is now quite a bit easier with Java 8 streams: you don't need the intermediate map to sort:
map.entrySet().stream()
.sorted(Map.Entry.comparingByValue())
.forEach(entry -> ... );