constarr=[{id:1,name:"小明",age:18,dreid:50},{id:2,name:"大热",age:18,dreid:52},{id:4,name:"妇女会计",age:18,dreid:51},{id:3,name:"千万",age:18,dreid:53},{id:1,name:"小强",age:18,dreid:51},{id:3,name:"千的",age:18,dreid:50},{id:2,name:"大巴",age:18,dreid:53},{id:4,name:"妇女放假",age:18,dreid:52},]我要把id相等的放在一个数组,dreid相等的放在一个数组变为这样的,数组的长度是不同id的长度letarr=[{dreid:50,//dreid相等的都放在listDreid数组中listDreid:[{id:1,name:"小明",age:18,dreid:50},{id:3,name:"千的",age:18,dreid:50},],id:1,//id相等的放在listId数组中listId:[{id:1,name:"小明",age:18,dreid:50},{id:1,name:"小强",age:18,dreid:51},]},{dreid:51,//dreid相等的都放在listDreid数组中listDreid:[{id:4,name:"妇女会计",age:18,dreid:51},{id:1,name:"小强",age:18,dreid:51},],id:2,//id相等的放在listId数组中listId:[{id:2,name:"大热",age:18,dreid:52},{id:2,name:"大巴",age:18,dreid:53},]},{dreid:52,//dreid相等的都放在listDreid数组中listDreid:[{id:2,name:"大热",age:18,dreid:52},{id:4,name:"妇女放假",age:18,dreid:52}],id:3,//id相等的放在listId数组中listId:[{id:3,name:"千万",age:18,dreid:53},{id:3,name:"千的",age:18,dreid:50},]},{dreid:53,//dreid相等的都放在listDreid数组中listDreid:[{id:3,name:"千万",age:18,dreid:53},{d:2,name:"大巴",age:18,dreid:53}],id:4,//id相等的放在listId数组中listId:[{id:4,name:"妇女会计",age:18,dreid:51},{id:4,name:"妇女放假",age:18,dreid:52},]}];这个怎么实现呢?
临摹微笑
阿波罗的战车
相关分类