I have a variable that sets the order of objects in a specific way:
const order = ['large', 'medium', 'small'];
My goal is to arrange the data array objects according to the names specified in the order array:
const data = [{name: "small", children: []}, {name: "medium", children: []}, {name: "large", children: []}]
The desired outcome would be:
const data = [{name: "large", children: []}, {name: "medium", children: []}, {name: "small", children: []}]
Can someone help me achieve this sorting?