详细代码如下:
var s=[{name:"abc",value:10},{name:"dbc",value:5},{name:"acc",value:15},{name:"ebc",value:50},{name:"bbc",value:80},{name:"aca",value:60}] //JS Object字符串排序 s.sort(function(a,b){ return a["name"].localeCompare(b["name"]); //localeCompare 字符串比较 })
时间: 2024-10-08 09:22:54