更新时间:2023-11-24 09:31:58
您必须填写此代码:
ArrayList<ArrayList<DriverLogDatePair>> driverLogList = new ArrayList<>();
Collections.sort( driverLogList, new Comparator<ArrayList<DriverLogDatePair>>(){
@Override public int compare(
ArrayList<DriverLogDatePair> left,
ArrayList<DriverLogDatePair> right )
{
return 0;
}});
因为第一个数组包含一个包含Comparable的数组。
您提供的比较器是为DriverLogDatePair而不是ArrayList< DriverLogDatePair>
Because the first array contains an array which contains a Comparable. The comparator you provide is for DriverLogDatePair not for ArrayList< DriverLogDatePair >
(...在此帖子的评论...)
(... After comments of this post... )
完成比较我建议:
int size = left.size();
int diff = size - right.size();
if( diff != 0 ) return diff;
for( int i = 0; i < size; ++i ) {
diff = left.get( i ).compareTo( right.get(i) );
if( diff != 0 ) return diff;
}
但我不知道这个比较的真正含义。
这是一个语义问题,这是真的你想要什么?
But I have no idea of the true meaning of this comparison. It's a semantic problem, is this really what you want?