I have two arrays of objects and I need to match the order of one of the arrays with the other. Here's an example:
const outOfOrderArray = [{field: 'foo'}, {field: 'bar'}, {field: 'bazz'}, {field: 'bizz'}];
const arrayInProperOrder = [{field: 'bizz'}, {field: 'bazz'}, {field: 'foo'}, {field: 'bar'}];
What can I do to make the outOfOrderArray match the order of objects in arrayInProperOrder?
const outOfOrderArray = [{field: 'foo'}, {field: 'foo'}, {field: 'bar'}, {field: 'bazz'}, {field: 'bizz'}]where{field: 'foo'}is appearing 2 times,