1. I have a set of data, and I want to group them according to a set of conditions, roughly as follows:
[{id: 1, name: "Sean", age: 22, sex: "Male"},
{id: 2, name: "Sean", age: 12, sex: "Male"},
{id: 3, name: "Tom", age: 21, sex: "Male"},
{id: 4, name: "John", age: 25, sex: "Male"}]
I want to classify according to a set of conditions. for example, ["name","age","sex"] currently has only three, but requires a wireless loop, for example, I get an array object when I finish dividing it for the first time.
{Sean:[
{id: 1, name: "Sean", age: 22, sex: "Male"},
{id: 2, name: "Sean", age: 12, sex: "Male"}
],
John:[
{id: 4, name: "John", age: 25, sex: "Male"}
],
Tom:[
{id: 3, name: "Tom", age: 21, sex: "Male"}
]
}
then I"m reclassifying according to this result. Get the data classified according to age, and then I reclassify by gender according to the data obtained by age. It"s a super disgusting cycle. I already have the method of classification. But how to write this recursion. Ask for expert advice. I really can"t figure it out.