对象数组,按照没想中特定的属性(按中文拼音)排序

        var objs = [
            {'name': 'A', 'type': 'fly'},
            {'name': 'B', 'type': 'blur'},
            {'name': 'C', 'type': 'wipe'},
            {'name': 'D', 'type': 'cube'},
            {'name': 'E', 'type': 'iris'},
            {'name': 'F', 'type': 'fade'}
        ];

        objs.sort(function(a,b){
            return a.type.localeCompare(b.type,"zh")
        });

        console.log(objs);//
0: {name: "B", type: "blur"}
1: {name: "D", type: "cube"}
2: {name: "F", type: "fade"}
3: {name: "A", type: "fly"}
4: {name: "E", type: "iris"}
5: {name: "C", type: "wipe"}
原文地址:https://www.cnblogs.com/fqh123/p/10973289.html