Sort objArray2 according to strArray1

the problems encountered in the project require an algorithm that satisfies the function, and the time complexity is as small as possible
two arrays strArray1 and objArray2 :

are known.
const strArray1 = [
    "a",
    "b",
    "c",
    ...
    "z"
]

const objArray2 = [
    {
        str: "c",
        ...
    },
    {
        str: "a",
        ...
    },
    {
        str: "z",
        ...
    },
    ...
    {
        str: "b",
        ...
    }
]

the length of the two arrays is the same. The elements in objArray2 correspond to strArray1 elements one by one, but disordered
now requires objArray2 to be sorted according to the order of strArray1 :

return = [
    {
        str: "a",
        ...
    },
    {
        str: "b",
        ...
    },
    {
        str: "c",
        ...
    },
    ...
    {
        str: "z",
        ...
    }
]
Oct.28,2021

function sortArr(strArray1, objArray2) {
  let rst = [...objArray2]

  // strArray1:{a: 0, b: 1, c: 2, d: 3, ...}
  let obj = strArray1.reduce((iter, val, idx) => {
    iter[val] = idx 
    return iter
  }, {})

  // sort
  rst.sort((a, b) => obj[a.str] - obj[b.str])

  return rst
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b371f8-2c098.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b371f8-2c098.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?