Is it possible, rather easily, to sort an array of objects by an array of IDs? Here's an example:
[{
id: "A",
name: "John"
}, {
id: "B",
name: "Bobby"
}, {
id: "C",
name: "Peter"
}]
Now I have an array of objects, each with an unique ID. I then have an array of IDs like so:
var ids = ["C", "A", "B"];
Would it be possible to sort the array of objects, so it ends up like this:
[{
id: "C",
name: "Peter"
}, {
id: "A",
name: "John"
}, {
id: "B",
name: "Bobby"
}]