JSFiddle - React, Tailwind, and code Playground
JavaScript
let jsons = [
{
"id": 10
},
{
"id": 4
},
{
"id": 1
},
]
let new_list = []
length = jsons.length
for(let i = 0; i < length; i++) {
let index = 0
let cur_lowest = 50000
for(let j = 0; j < jsons.length; j++) {
if(jsons[j].id <= cur_lowest) {
cur_lowest = jsons[j].id
index = j
}
}
new_list.push(jsons[index])
jsons.splice(index, 1)
}
console.log(new_list);