I have 2 objects where I want the second one to be in the same order as the first one.
Ex:
const obj1 = [
  { key: 1, id: 1, name: "John" },
  { key: 2, id: 2, name: "Ann" },
  { key: 3, id: 3, name: "Kate" }
];
const obj2 = [
  { key: 2, id: 2, name: "Ann" },
  { key: 1, id: 1, name: "John" },
  { key: 3, id: 3, name: "Kate" }
];
The purpose is to have obj2 in same order as obj1, but only sort with keys. I'm trying to make an helper function which will pass 3 argument:
function helper(obj1, obj2, key) {
  // return new object with sorted array do not modify existing
}
I can sort one of this, but cant combine 2object together
 
     
     
     
    