js數組中文排序

var arr = ['綿陽', 'aaa', '資陽', 55, '成都', 2, 'chengdu','abc']; var result = arr.sort(function(a, b){return (a + '').localeCompare(b + '')}); console.log(result); //[2, 55, "成都", "綿陽", "資陽", "aaa", "abc
相關文章
相關標籤/搜索