Skip to main content

Java Map

Sort entries by key

fileNamesToSize.entrySet().stream().sorted(Map.Entry.comparingByKey()).forEachOrdered(entry -> {
System.out.println(entry.getKey());
System.out.println(entry.getValue());
});