let data = [
{
count:"8",
name: "21-09"
},{
count:"8",
name: "20-11"
},{
count:"8",
name: "20-12"
},{
count:"8",
name: "21-01"
}
]
data.sort(function (a,b){
return a.name > b.name ? 1 : -1 //升序 < 降序
})
console.log(data); //(4) [{…}, {…}, {…}, {…}]
0: {count: '8', name: '20-11'}
1: {count: '8', name: '20-12'}
2: {count: '8', name: '21-01'}
3: {count: '8', name: '21-09'}
length: 4
[[Prototype]]: Array(0)