so I'm trying to find any way to separate this array based on ID's.
[ [ 1, 123412341234, 2.44 ], [ 1, 123912341234, 23.44 ], [ 1, 623412341234, 82.44 ], [ 2, 123412341234, 22.44 ], [ 2, 123412381234, 2.44 ], [ 2, 723412341234, 29.44 ], [ 3, 123412341234, 24.44 ], [ 3, 123412377234, 34.44 ], [ 3, 520312341234, 54.44 ], [ 4, 123412341234, 12.44 ], [ 4, 938412341234, 19.44 ], [ 4, 603412341234, 10.44 ] ]
weather in separate array or in the same array but with an additional [] around the data with same ID
so this
[
[[ 1, 123412341234, 2.44 ], [ 1, 123912341234, 23.44 ], [ 1, 623412341234, 82.44 ]],
[[ 2, 123412341234, 22.44 ], [ 2, 123412381234, 2.44 ], [ 2, 723412341234, 29.44 ]],
[[ 3, 123412341234, 24.44 ], [ 3, 123412377234, 34.44 ], [ 3, 520312341234, 54.44 ]],
[[ 4, 123412341234, 12.44 ], [ 4, 938412341234, 19.44 ], [ 4, 603412341234, 10.44 ]]
]
or this
[[ 1, 123412341234, 2.44 ], [ 1, 123912341234, 23.44 ]]
[[ 2, 123412341234, 22.44 ], [ 2, 123412381234, 2.44 ], [ 2, 723412341234, 29.44 ]]
[[ 3, 123412341234, 24.44 ], [ 3, 123412377234, 34.44 ], [ 3, 520312341234, 54.44 ]]
[[ 4, 123412341234, 12.44 ], [ 4, 938412341234, 19.44 ], [ 4, 603412341234, 10.44 ]]
This is what I tried to make by myself but it's not working ( the c[i] is not working)
for(let i = 0; i < this.z.length;i++) {
for (let j = 0; j < this.z.length; j++) {
if(this.z[j][0]==i){
this.c[i].push(this.z[j])
}
}
}
sort()with a custom sorting function?