I have an array of objects with the _id index
[{
_id: 'zzz'
}, {
_id: 'abc'
}, {
_id: 'xxx'
}, {
_id: '123'
}, {
_id: 'several other objects not in the array'
}]
I also have an array like this
['abc', '123', 'xxx', 'zzz']
how can I make sure that the array of objects is correctly ordered by the array given?
I'm using 2 for loops but really looks ugly, and I'm sure there's a better way for this. thanks!