Looking to filter and sort a nested tree object for a menu
If the status for sorting and filtering is true, how do I proceed?
const items = [{
name: "a1",
id: 1,
sort: 1,
status: true,
children: [{
name: "a2",
id: 2,
sort: 1,
status: true,
children: [{
name: "a3",
id: 3,
sort: 2,
status: true,
},
{
name: "a5",
id: 4,
sort: 1,
status: true,
}
]
}]
},
{
name: "b2",
id: 2,
sort: 2,
status: true,
children: [{
name: "a2",
sort: 1,
status: false,
id: 2,
children: [{
name: "a3",
id: 3,
sort: 1,
status: true,
}]
},
{
name: "a4",
id: 8,
sort: 2,
status: true,
}
]
}
];
console.log('items:', items)
const items = [{
name: "a1",
id: 1,
sort: 1,
status: true,
children: [{
name: "a2",
id: 2,
sort: 1,
status: true,
children: [{
name: "a5",
id: 4,
sort: 1,
status: true,
},
{
name: "a3",
id: 3,
sort: 2,
status: true,
}
]
}]
},
{
name: "b2",
id: 2,
sort: 2,
status: true,
children: [{
name: "a4",
id: 8,
sort: 2,
status: true,
}]
}
];