I have an array of objects similar to this:
[
{
ref: "CTB98",
name: "Joe"
},
{
ref: "HTF76",
name: "Alice"
},
{
ref: "JHU90",
name: "Tom"
},
{
ref: "ADF56",
name: "Mary"
}
]
And in another array I have the exact order that they are meant to be in, referenced by their ref
property:
["JHU90", "HTF76", "CTB98", "ADF56"]
I'd like to rearrange the order of the first array of objects, so that the ref values on each object follow the same order as the values in my reference array above.
I'm new to computer science, so I will select the answer with best explanation of the technique.