这个数组怎么排序,按照名字相同
var arr = [
{"name":"张三","value":"111"},
{"name":"李四","value":"11111"},
{"name":"张三","value":"25462"},
{"name":"李四","value":"23131"},
{"name":"王五","value":"2315432"},
{"name":"李四","value":"333333"}
];
回答:
arr.sort((a,b)=>{ return a.name.localeCompare(b.name)})
回答:
arr.sort(function(a, b) { return new Intl.Collator('zh').compare(a.name, b.name);
});
以上是 这个数组怎么排序,按照名字相同 的全部内容, 来源链接: utcz.com/p/936526.html