I have a multidimensional array like that:
original_array[0] = Array(20 elements) # Titles
original_array[1] = Array(20 elements) # Values
I have splited this array ever 10 columns:
@splited_array = Array.new
@original_array.each do |elem|
@tmp = Array.new
elem.each_slice(10) do |row|
@tmp << row
end
@splited_array << @tmp
end
# Result:
# splited_array[0][0] => labels 1 to 9
# splited_array[0][1] => labels 10 to 19
# splited_array[1][0] => values 1 to 9
# splited_array[1][1] => values 10 to 19
Now I will merge to this result:
# splited_array[0][0] => labels 1 to 9
# splited_array[0][1] => values 1 to 9
# splited_array[1][0] => labels 10 to 19
# splited_array[1][1] => values 10 to 19
What the best way to do this? Any help will be highly appreciated