【发布时间】:2015-12-12 20:02:51
【问题描述】:
我有一个以字符串为键、对象为值的 HashMap。如何按 Objects 中的 FirstName 字段对 HashMap 进行排序。这是实际的 HashMap 表示 HashMap<String, AttendanceData> attendanceDataMap=new HashMap<String, AttendanceData>();
HashMap 的键是 AttendanceData 对象的 id
AttendanceData 类的样子
public class AttendanceData{
private TakenBy takenBy;
private String id;
private String user_name;
private String first_name;
private String description;
private String last_name;
public AttendanceData(String id, String firstName, String lastName, String takenBy, String description, String userName)
{
this.id=id;
this.first_name=firstName;
this.last_name=lastName;
this.takenBy=takenBy;
this.description=description;
this.user_name=userName;
}
【问题讨论】:
-
比较器在这里会有所帮助
标签: android collections hashmap