引用
require 'matrix'
arr = [["a1","a2","a3","a4"],["b1","b2","b3","b4"],["c1","c2","c3","c4"]]
change_arr = Matrix.columns(ww)
change_aee.to_a
p #=> [["a1","b2","c3"],["a2","b2","c2"],["a3","b2","c3"],["a4","b4","c4"]]
ruby矩阵用法参考
http://www.kuqin.com/rubycndocument/man/addlib/Matrix.html
另外hash转二维数组:
Array({:a => "a", :b => "b"}) #=> [[:a, "a"], [:b, "b"]]
数组转hash
[[:a, "a"], [:b, "b"]].to_h #=> {:a => "a", :b => "b"}