【发布时间】:2020-02-14 10:34:27
【问题描述】:
public int compareTo(T o){
if (this.getId().charAt(0) < o.getId() ){
return 1;
}else{
return -1;
}
//Id data = a, b, f, z
//num data = 1, 2, 4, 8
//i want to sort the list according to their id first. then also sort it with their 'num' after sorting with their id first
//sort id first. sort according to num after
}
}
我想先根据他们的 id 对列表进行排序。然后根据num。我会怎样..
【问题讨论】:
-
这能回答你的问题吗? Sort a List of objects by multiple fields