Is there a way to sort one array to match the order of another array with identical content, based on a shared property?
For instance:
let firstArray = [{id: 123, ...}, {id: 456, ...}, {id: 789, ...}] // always in this order
let secondArray = [{id: 456, ...}, {id: 789, ...}, {id: 123, ...}] // always different order
I want to rearrange firstArray so that:
firstArray[0].id
is 456 and
secondArray[0].id
is 456