# sorting through array ?

I have a sorting and collecting question say i have a array with 18 elements and each element is storing 5 numbers i want to collect each of the 5 numbers out of the that index of the array and store there values into different arrays what would be the easiest and dryest way of complete this task

example array[0..18] array[0] => [ 1 2 3 4 5 ]

thanks for any help

Gabriel G

GabrielG1976 wrote:

I have a sorting and collecting question say i have a array with 18 elements and each element is storing 5 numbers i want to collect each of the 5 numbers out of the that index of the array and store there values into different arrays what would be the easiest and dryest way of complete this task

example array[0..18] array[0] => [ 1 2 3 4 5 ]

thanks for any help

Gabriel G

"store their values into different arrays" - can you supply more details about what you want to do with the numbers?

What it is a Golf score keeper each of the game[0..17] array elements is a round or 1 hole in golf the first number is what par is and each of the 4 golfers strokes taken at that hole game[0] => [ 1 2 3 4 5 ]

GabrielG1976 wrote:

What it is a Golf score keeper each of the game[0..17] array elements is a round or 1 hole in golf the first number is what par is and each of the 4 golfers strokes taken at that hole game[0] => [ 1 2 3 4 5 ]

what about something like (I assume you want five arrays out of this) If round is your starting array like [[4, 4, 3, 4, 5],[4, 4, 4, 4, 5],[3, 2, 3, 3, 4],...] (yeah, that last golfer must be me)

par = golfer1 = golfer2 = golfer3 = golfer4 = round.each do |scores|   par << scores[0]   golfer1 << scores[1]   etc end

I'm sure there's a more cryptographic way to do it that takes less keystrokes, but I value clarity.

Thanks for everyones help

Gabriel