Hi I would like to map over an array and sort it depending on an lookup object.
const obj = {
"email": {position: 1, name: "email"},
"firstname": {position: 2, name: "firstname"},
"lastname": {position: 3, name: "lastname"}
}
const arr = ["lastname", "email", "firstname"];
expected output: ["email", "firstname", "lastname"];
I know that I must use the map function in order to return a new array. I can get an new array with the full or object or retrieving only a array with all names or position properties. But I cannot figure out how to sort them.
Thanks for your help