title: Join elements in 2D array with similar values
body: <p>So my array is as follows:</p>
  <pre><code>array = [ [5, type1, quantity1, price1] , 
        [2, type2, quantity2, price2] ,
        [2, type1, quantity3, price1]
      ]
  </code></pre>
  <p>The above values are not constant and they can vary. Whats important is that they match and they add together creating 1 element.</p>
  <p>So, since <code>array[0]</code> and <code>array[2]</code> have the same type and price (<code>array[n][1] and array[n][3]</code>), the resulting array should look like:</p>
  <pre><code>[ [7, type1, quantity1+quantity3, price1], 
    [2, type2, quantity2, price2]
  ]
  </code></pre>
  <p>The array has an N length. I'm trying to find the optimal algorithm to do this but I can't find it.</p>
  <p>Thanks in advance.</p>