Grouping 2D arrays & transforming to hash : I have a two dimensional array and I wanted to group it by one of the attributes within the array. The values in the attributes stored in the array are sales_user, user_id, month, and amount. 

    array = [[8765, 105191, 2.0, 1582.1],
            [4321, 62770, 2.0, 603.24], 
            [4321, 105191, 2.0, 1900.8],
            [1234, 62770, 2.0, 603.24]]

Index[0] in each array is the sales_user and I wanted to group by that. 
I need to get it to: 

    [[8765, [105191, 2.0, 1582.1]]
    [[4321, [[62770, 2.0, 603.24]],[[105191, 2.0, 1900.8]]]
    [1234, [[62770, 2.0, 603.24]]]]

I tried doing this:
array.group_by(&:first).map { |c, xs| [c, xs] } 

    [[8765, [[8765, 105191, 2.0, 1582.1]]], 
    [4321, [[4321, 62770, 2.0, 603.24], ][4321, 105191, 2.0, 1900.8]]],
    [1234, [[1234, 62770, 2.0, 603.24]]]]

It almost gave me what I wanted but it included the sales_user inner array as well :/ 

I would like to transform the grouped array to a hash as well. Is this easily possible in ruby? I'm fairly new to it ^^" Or maybe I need to conver the original array to a hash and then do the group by sales_user? 