I am working with a multi-dimensional array like below
[
[203, 541, 5001, 6.8, 207, 30252],
[203, 542, 5001, 16.3, 83, 50832],
[203, 542, 5001, 60.9, 207, 30252],
[203, 542, 5003, null, 207, 30252],
[203, 541, 5001, 15, 965, 52452],
[203, 542, 5003, 6.8,207, 30252],
[203, 542, 5003, null, 207, 30252],
[203, 541, 5001, 15, 965, 52452],
[203, 542, 5003, 6.8,207, 30252]
]
Where the first 3 elements are ID ints, and the last 3 are count floats. I am trying to be able to group these based on the first 3 elements and add the counts (individually) so I would end with an array like below
[
[203, 541, 5001, 36.8, 1937, 30252], // Sum the last 3 elements that have 203,541,5001 as the beginning 3 elements of the array
[203, 542, 5001, 77.2, 290, 81084], // Sum the last 3 elements that have 203,541, 5001 as the beginning 3 elements of the array
[203, 541, 5003, a, b, c], // same as above
[203, 542, 5003, x, y, z] // same as above
]
Without looping through all arrays, creating temp counters, then looping through each array element to add the last 3 elements to the temp counters and then pushing the result to a result array, is there a way to group these and add at the same time?