my question is somewhat similar to javascript | Object grouping .
my input obj is
[
{
\"name\":\"Display\",
\"group\":\"Technical detals\"
Without sorting you may group by the provided property (by
) as follows;
function quasiSort(a,by){
var h = a.reduce((h,e) => h[e[by]] ? (h[e[by]].push(e), h)
: (h[e[by]] = [e], h), {});
return Object.keys(h).reduce((r,k) => r.concat(h[k]),[]);
}
var data = [{ "name":"Display",
"group":"Technical detals",
"id":"60",
"value":"4"
},
{ "name":"Manufacturer",
"group":"Manufacturer",
"id":"58",
"value":"Apple"
},
{ "name":"OS",
"group":"Technical detals",
"id":"37",
"value":"Apple iOS"
}
];
console.log(quasiSort(data,"group"));