I have an array
const arr = [
{label: 'a', width: 200},
{label: 'b', width: 200},
{label: 'c', width: 200},
{label: 'd', width: 200},
{label: 'e', width: 200}
];
given another array
const data = ['d', 'e', 'a', 'c', 'b'];
It need's to re-arrange first array based on the new data.
What function should I use in javascript?
Edit: Thank you for very interesting comments. But to make it more complicated, let's assume that data could also be not the full list of the first array.
const data = ['a', 'c'];
and it still should outcome the first array where first two elements are a & c, and remaining ones are b, d, e. Finished array should be in a list of a, c, b, d, e.