I have got a 2d list array to which I am adding characters in a loop like below. I need to be able to sort in lexiographical order each sub container of of the 2d array. Unfortunately, Collections.sort(list) does not work in this case.
我有一个2d列表数组,我在下面的循环中添加字符。我需要能够按照lexiographical顺序对2d数组的每个子容器进行排序。不幸的是,Collections.sort(list)在这种情况下不起作用。
List<Character>[][] list = new LinkedList[n][n];
for (int j = 0; j < n; ++j)
{
for (int m = 0; m < 1; m++)
{
// Here is the problem
list[j][m].add(new Character('b'));
// sort the array and continue
}
}
1 个解决方案
#1
1
If you want to compare a list of a lists, I suggest you to use the ColumnComparator class:
如果要比较列表列表,我建议您使用ColumnComparator类:
#1
1
If you want to compare a list of a lists, I suggest you to use the ColumnComparator class:
如果要比较列表列表,我建议您使用ColumnComparator类: