【发布时间】:2021-03-17 12:23:04
【问题描述】:
我有一个清单:
List<A> aList
where A:
public class A{
private Long id;
private LocalDate created;
private AStatus status; //enum
...other fields
}
public enum AStatus{
NEW, SEND, WAITING, CANCELLED
}
如何按 DESC 顺序按 created 对我的列表进行排序,然后我希望将状态为 NEW 的元素作为第一个(然后是其他 AStatus 的元素),例如:
1 10.12.2020 NEW
2 10.12.2020 SEND
3 10.12.2020 CANCELLED
4 08.12.2020 NEW
5 08.12.2020 NEW
【问题讨论】:
-
如果我们有例如。 3 行具有相同的日期,然后状态 NEW 必须始终位于列表的顶部(作为 FIRST,在同一日期的其他 AStatus 之前)