The TreeMap keeps its keys in order. We create TreeMap objects and use them to accumulate values.
The program shown creates a new TreeMap called rList.
We are not using the value at all, only the keySet is of interest.
Print each region.
Each value of the rList TreeMap accumulates
the total population.
We initialise each value as 0L if required.
Print the total population of each region.
Notice how we initialise each region once - when we come across a region that is not in the TreeMap already:
if (!rList.containsKey(c.region)) rList.put(c.region,0L);