I\'m trying to condense summable metrics to a unique identifier in a ruby table.
I have the following table:
[[\"id1\", 123], [\"id2\", 234], [\"id1\", 3
As condensed as it can get.
array = [["id1", 123],["id2", 234], ["id1", 345]] array.group_by(&:first).collect{|key,values| [key,values.reduce(0) {|sum,a| sum+a[1]}]}