JS regroups the array?

suppose a group leader is like this

    var qq = [
      
    
          [
              {
                "group": 100,
                "info": {"event": 123},
                "main": true,
              },
              {
                "group": 100,
                "info": {"event": 323},
                "main": false,
                "sp": 12
              },
               {
                "group": 103,
                "info": {"event": 123},
                "main": false,
                "sp": 1
              }
          ],
          [
              {
                "group": 103,
                "info": {"event": 123},
                "main": true,
                "sp": 13,
              },
              {
                "group": 103,
                "info": {"event": 323},
                "main": false,
                "sp": 10
              }
          ]
          ];

how can this be implemented?

Apr.19,2022

how about this?


lodashgroupBy,

_.groupBy(qq, item => item.group)



![clipboard.png](/img/bVbm9PL)

the rest of the processing should be simple.

you can do this if you want to implement it yourself

let result = [];

for(let i=0; i<qq.length; iPP) {
    let group = qq[i]['group'];
    let filterArr = qq.filter(item => item.group === group).sort((a,b) => b.sp - a.sp);
    result.push(filterArr);
    i += filterArr.length - 1;
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b370bd-2c078.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b370bd-2c078.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?