I have this data :
[
["A","X1","Y1"],
["A","X2","Y2"],
["A","X3","Y3"],
["B","X4","Y4"],
["B","X5","Y5"],
["B","X6","Y6"],
]
and would like to change the array structure to be this :
[
["A",["X1","Y1"],["X2","Y2"],["X3","Y3"]],
["B",["X4","Y4"],["X5","Y5"],["X6","Y6"]],
]
I have been playing around with flatten function (flatten with a 'key' (i.e A and B) and then join all back together at the end.) - but the 'key' change from A to B (and potentially to C, D, E ....) has got me stumped.
I would appreciate any pointers as to the most efficient direction to go. Has any one else met this type of need ? Is there a better way (outside nested interations)