【发布时间】:2017-07-28 06:44:32
【问题描述】:
我有一个 Map> 这里的键是 Employee 的 EmpId,键将包含 List
BonusEntity 将包含以下字段(所有字段均为字符串)
Empid 奖金日期 奖金金额 部门
我需要根据 BonusDate 降序对 Map 中的 ArrayList 进行排序,谁能帮忙提前谢谢。
【问题讨论】:
-
请提高您的提问质量。您可以在以下位置找到更多提示:How do I ask a good question? 和 How to create a Minimal, Complete, and Verifiable example 页面。
-
实体类可以实现 Comparable 实现 Compare to as @Override public int compareTo(BonusEntity o) { return o.bonusdate.compareTo(this.bonusdate);并使用 Collections.sort(list) 对列表进行排序;请记住,使用字符串来保存日期值会给您带来一些意想不到的结果,请使用 Date 类而不是字符串
标签: java sorting arraylist collections