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
:
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",
...
}
]