法一
let arr = [ { name:'cas' }, { name:'ras' }, { name:'das' }, { name:'aas' }, ] arr.sort((a,b)=>{ return a.name[0].charCodeAt(0)-b.name[0].charCodeAt(0) }) console.log(arr);
法二
let arr = [ { name:'cas' }, { name:'ras' }, { name:'das' }, { name:'aas' }, ] arr.sort((a,b)=>a.name[0].localeCompare(b.name[0])) console.log(arr);