hope everyone doing well!
Is there anyone in here who can help how to group the below array to object sort by the second item of each record in Javascript?
i.e: "{first},{second},{third},{fourth}" -> "bob,627,1973,Amsterdam"
Take for example this array:
[
'bob,627,1973,amsterdam',
'alice,387,885,bangkok',
'alice,355,1029,barcelona',
'alice,587,402,bangkok',
'charlie,973,830,barcelona',
'alice,932,86,bangkok',
'bob,188,989,amsterdam'
];
expected result:
{
alex: [
[ 355, '1029', 'barcelona' ],
[ 387, '885', 'bangkok' ],
[ 587, '402', 'bangkok' ],
[ 932, '86', 'bangkok' ],
],
bob: [
[ 188, '989', 'amsterdam' ],
[ 627, '1973', 'amsterdam' ],
],
charlie: [
[ 973, '830', 'barcelona' ],
],
}