I just want to know how I can sort by chnrological order a Map<LocalDate, Integer>.
Here's the first line of my code :
Map<LocalDate, Integer> commitsPerDate = new HashMap<>();
Afterwards, I fill in my Map with any value (but not in chronological order). And when I display the values of my Map, it is displayed in this order :
for(var item : commitsPerDate.entrySet()) {
System.out.println(item.getKey() + " = " + item.getValue());
}
2020-08-31 = 1
2020-09-30 = 3
2020-09-29 = 1
2020-09-28 = 5
2020-09-27 = 5
2020-08-27 = 4
2020-09-25 = 3
2020-10-21 = 1
2020-10-18 = 1
2020-10-17 = 5
2020-10-16 = 4
2020-10-15 = 5
2020-10-14 = 6
2020-09-14 = 1
2020-10-13 = 2
2020-09-13 = 2
And I would like it to be sorted in chronological order so that the display is in the same order.
Thank you.