How to put a specific element in an array first

suppose there is an array like this

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

group is in the same group as the number.
I want to put sp 1 in the first group in the same group, and change main to false.
how to achieve this? Is there a big god who can try it for me?

the end result should be like this

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

var group, index = -1;
for (var i = 0; i < qq.length; iPP) {
    var obj = qq[i];
    if (group !== obj.group) index = i;
    if (obj.sp === 1 && obj.group === group) {
        obj.main = false;
        qq.splice(i, 1);
        qq.splice(index, 0, obj);
    }
    group = obj.group;
}
console.log(qq);
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-1eae766-47fb1.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-1eae766-47fb1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?