score:0

Accepted answer

please change the people variable. from '[,]' to '{,}'.

const people = {
     1:{
       id : 1,
       name: 'james',
       age: 31,
       tobedeleted: false,
       position: 2
     },
     2:{
       id : 2,
       name: 'john',
       age: 45,
       tobedeleted: true,
       position: 3
     },
     3:{
       id : 3,
       name: 'paul',
       age: 65,
       tobedeleted: false,
       position: 1
     }
};

const sorted = object.values(people)
       .filter((people) => people.tobedeleted !== true)
       .sort((a, b) => a.position - b.position);
console.log(sorted);


Related Query

More Query from same tag