根据数组中每个对象中的某个属性值进行排序
作者:互联网
let arr = [{'sd':'1','content':'这是上午'},{'sd':'2','content':'这是中午'},{'sd':'3','content':'这是下午'}]
arr.sort(this.compare('sd'))
compare(property){
return function(a,b){
let value1 = a[property]
let value2 = b[property]
return value1 - value2
}
}
标签:arr,property,属性,content,let,value2,数组,排序,sd 来源: https://blog.csdn.net/qq_42504734/article/details/120128563