This is not my real code I have just simulated in order to understand what to do next.
I have class Person with properties age, height weight.
Now In my class Group
I create two four objects
Person programmer, student, clerk, tech;
I have HashMap rollCall
Map<Person, Integer> rollCall = new HashMap<Person, Integer>();
to add all these using Person and number of Persons as type Integer
rollCall.put(programmer, 1);
rollCall.put(clerk, 2);
rollCall.put(student, 1);
rollCall.put(tech, 3);
I have seen alot of people sorting HashMap using TreeMap on value I want to sort on a property of Person rather on value. I want to sort all these people on their age (i.e. programmer.getAge();). I am not sure if I will use comprator which works only on collection not map. . Please help ... .