小白,请教各位大佬!如何把数组內 特定元素放到第一个求指导!

假设有一个数组是这样
varqq=[
{
"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是同数字表示是一组的,我想把sp是1的,都放到同组的第一个,并且把main改成false,这具体该怎么实现?有大神可以帮我试试吗
最终结果要是这样
varqq=[
{
"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
}
];
POPMUISE
浏览 260回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript