I have this HashMap,
private static Map<String, Integer> messageCount = new HashMap<>();
which i'm trying to get sorted by the value. I found this code:
Map<String, Integer> sorted = Server.getMessageCount().entrySet().stream().sorted(Map.Entry.comparingByValue()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue,
(e1, e2) -> e1, HashMap::new));
which theoretically should sort it by the Integer Value, but the Map is still getting sorted alphabetically (by key).
(I use this to output my map, but i'm pretty sure that this isn't the problem (or is it?))
System.out.println(Arrays.toString(sorted.entrySet().toArray()));