js实现按照首字母排序

<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>

js实现按照首字母排序

 

上一篇:HTTPS--CA认证


下一篇:SSL 根证书的相关概念