最简单的ruby代码对此表进行排序,以便在第一列上进行排序 按升序排序,而在第二列按降序排序
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] ]
结果表应为:
[[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] ]
任何帮助表示赞赏, 泰德