var reconstructQueue = function(people) {
const sorted = [...people].sort(sortPeople);
const result = [];
for(let i = 0; i < sorted.length; i++){
result.splice(sorted[i][1], 0, sorted[i]);
}
return result;
};
const sortPeople = (a, b) => {
if(a[0] !== b[0]){
return b[0] - a[0];
} else {
return a[1] - b[1];
}
}