I have an array that look like this
var array = [{id:5},{id:1},{id:2}]
I want to rearrange the array index based on the id value from lowest to highest so it becomes
var newarray = [{id:1},{id:2},{id:5}]
I have been looking at sort() but I dont quite understand the logic behind it.
array.sort((a, b) => a.id - b.id)sortfunction. They OP can apply it to their needs