What would be the simplest ruby code to sort this table so that on the first column it
is sorted in ascending order, while in the second column it is sorted in descending order
matrix = [ [1,1],
[2,1],
[2,4],
[2,3],
[2,2],
[3,1],
[4,2],
[4,3],
[4,4],
[1,4],
[1,3],
[1,2],
[3,2],
[3,4],
[3,3],
[4,1] ]
Resulting table should be:
[[1,4],
[1,3],
[1,2],
[1,1],
[2,4],
[2,3],
[2,2],
[2,1],
[3,4],
[3,3],
[3,2],
[3,1],
[4,4],
[4,3],
[4,2],
[4,1] ]
Any help appreciated,
Ted
I think that’s the simplest but according to the docs, it can be quite expensive when the keysets are simple.