const arr = [{a:'data'},{a:'code'},{a:'data.total'},{a:'data.list'},{a:'daca.last'}] function sortFn(arr,attr) { let result1 = arr.map((item)=>{return item[attr]}).sort() let result2 = [] result1.forEach(item=>{ result2.push(arr.find((el)=>{return el[attr] === item})) }) return result2 } console.log(sortFn(arr,'a'))