This is not my real code that I just modeled to figure out what to do next.
I have a Person class with age, height weight properties.
Now in my class class
I create two four objects
Person programmer, student, clerk, tech;
I have a HashMap rollCall
Map<Person, Integer> rollCall = new HashMap<Person, Integer>();
to add all this using Person and the number of people as an Integer type
rollCall.put(programmer, 1); rollCall.put(clerk, 2); rollCall.put(student, 1); rollCall.put(tech, 3);
I have seen many people sorting a HashMap using TreeMap on value. I want to sort by Person property, not by value. I want to sort all of these people by their age (i.e. Programmer.getAge ();). I'm not sure if I will use a composite element that works only on the collection, not on the map. Please help ....
source share