title: Grouping an array on the basis of its first element, without duplication in Ruby
body: <p>I'm executing an active record command <em>Product.pluck(:category_id, :price)</em>, which returns an array of 2 element arrays:</p>
  
  <pre><code>[
    [1, 500],
    [1, 100],
    [2, 300]
  ]
  </code></pre>
  
  <p>I want to group on the basis of the first element, creating a hash that looks like:</p>
  
  <pre><code>{1 =&gt; [500, 100], 2 =&gt; [300]}
  </code></pre>
  
  <p>group_by seems logical, but replicates the entire array.  I.e. <em>a.group_by(&amp;:first)</em> produces:</p>
  
  <pre><code>{1=&gt;[[1, 500], [1, 100]], 2=&gt;[[2, 300]]}
  </code></pre>