<script type="text/javascript"> let obj = [{name:'CA'},{name:'XA'},{name:'CB'},{name:'XE'},{name:'CC'},{name:'XF'},{name:'CA'}] let bb = obj.sort((a,b)=>{a.name.charCodeAt(0)-b.name.charCodeAt(0)}) let cc = obj.sort((a,b)=>a.name.localeCompare(b.name)) console.log(bb) console.log(cc) </script>