There are two pieces here. One is turning it into an arrays of arrays,
the
other is transposing. If the order matters, use this to get the array of
arrays:
arr = [:colA, :colB, :colC].map { |k| hash[k] }
…otherwise:
arr = hash.values
Once you have an array of arrays, there is already a transpose method:
arr = arr.transpose
Thanks
–Greg
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.