how do you get the maximum per key for an Array [(Int,Double)] and then aggregate them
<p>how do we the most efficient way to getting the maximum values for an Array[(Int,Double)] and then aggregate it to get sum</p>

<p>example:</p>

<pre><code>  Array[(Int, Double)] = Array((0,2.0), (1,1.0), (1,1.0), (2,2.0), (2,1.0))
</code></pre>

<p>aggregate: 7</p>

<p>result </p>

<pre><code>    Array[(Int, Double)] = Array((0,2.0), (1,1.0), (2,2.0))
</code></pre>

<p>aggregate : 5</p>