java - sort arrays of array in lexiographical order -
i wondering how can sort arrays of array. example, have got char array like
0[a,b] 1[b,a] 2[a,a] and should sorted to:
0[a,a] 1[a,b] 2[b,a] in other words want sort different array locations in lexicographical order.
you can define implementation of comparator<t> that, t array of type wish sort lexicographically:
string[][] = ... arrays.sort(a, new comparator<string[]>() { compare(string[] lhs, string[] rhs) { // compare lhs rhs, , return result indicates // 1 comes earlier lexicographically } });
Comments
Post a Comment