我有一个员工集合。每个员工都有一个 ID。此 ID 号的格式为 -x >= 0 >= x 。我必须将员工排序为 0...x -1....-x。我怎样才能做到这一点??
List<Employee> empSort = new ArrayList(em.getEmployees());
Collections.sort(empSort, new Comparator<Employee>() {
@Override
public int compare(Employee p1, Employee p2) {
// WHAT LOGIC SHOULD I DO THERE TO HAVE THEM
SORTED AS 0...x -1....-x
}
});