let groups = { };
array . foreach(function(o ){
var group = JSON . stringify(f(o));
groups【group】= groups【group】| |【】;
群組【群組】。push(o);
});
返回Object.keys(組)。地圖(功能(組){
返回組【group】;
});
};
const arrayGroupBy =(list,groupId)= & gt;{
let sorted = group by(list,function(item ){
return【item【groupId】】;
});
返回已排序的;
};
ArrayGroupBy(數組,‘字段名‘);