I'm trying to sort a HashMap by value then by key which this post has a great solution...
Sort Hashmap by value and then alphabetically
Using lambdas. Specific line of code...
map.entrySet().stream()
.sorted(Map.Entry.<String, Integer>comparingByValue()
.reversed()
.thenComparing(Map.Entry.comparingByKey()))
.forEach(System.out::println);
Is there any way to format the output though? I'd like to handle the formatting as opposed to using the default format output. Is the only way to do this is to override the toString method?
Currently the format is Key=Value
but would like it to be Key Value
and format the value by a specified number of decimals.