I have an object that is being returned from a database like this: [{id:1},{id:2},{id:3}]. I have another array which specified the order the first array should be
[{id:1},{id:2},{id:3}]
Why not just create new array and push the value from second array in?? Correct me if i wrong
array1 = []; array2 = [2,3,1]; for ( var i = 0; i < array2 .length; i++ ) { array1.push({ id : array2[i] }) }