Possible Duplicate:
How to sort a Map<Key, Value> on the values in Java?
Suppose am having a map like
Map<String, Student> studDetails = new HashMap<String, Student>();
And the map contains entries like
studDetails.put("1",student1);
studDetails.put("2",student2);
studDetails.put("3",student3);
studDetails.put("4",student4);
Student entity is Something like
Class Student{
private String studName;
private List<Group> groups;
}
Group entity will be like
Class Group{
private String groupName;
private Date creationDate;
}
OK, so what I need is when am displaying student details, it will be in the order of group creation date. So if student is mapped to more than one group, we can take the creationDate of first group.
How can I given the soring on my HashMap studDetails
using this scenario.?
Can anyone help..please..