js对abc进行排序

220 阅读1分钟

 

function sortByPhaseName(list){
    if(list && list.length > 0){
        Array.prototype.sort.call(list,function(a,b){
            var name1 = a.name.replace('相','');
            var name2 = b.name.replace('相','');
            return name1.charCodeAt(0) - name2.charCodeAt(0);
        })
    }
}