I have the following array
array1 = [{
category: "Age"
id: "11"
},
{
category: "Gender"
id: "M"
},
{
category: "Age"
id: "23"
},
{
category: "Gender"
id: "F"
},
{
category: "Education"
id: "Graduate"
},
{
category: "Age"
id: "55"
}
]
I want this to group by category, something like this
groupedArray = [{
category: "Age",
groupedCat: [{
category: "Age"
id: "11"
},
{
category: "Age"
id: "23"
},
{
category: "Age"
id: "55"
}
],
category: "Gender",
groupedCat: [{
category: "Gender"
id: "M"
},
{
category: "Gender"
id: "F"
}
],
category: "Education",
groupedCat: [{
category: "Education"
id: "Graduate"
}]
}]