I have a groovy list of lists i.e.
list = [[2, 0, 1], [1, 5, 2], [1, 0, 3]]
I would like sort it by order of the first element, then second, th
If you want to sort arrays of arbitrary (though homogenous) length, you can use this and it will do it in a single pass:
def list = [[2, 0, 1], [1, 5, 2], [1, 0, 3]]
list.sort { a, b ->
for (int i : (0.. b[i])
if (comparison) return comparison
}
return 0
}
assert list == [[1, 0, 3], [1, 5, 2], [2, 0, 1]]