-
原数据
image.png
- 正序
function sortDate(a,b){
return a.createTime > b.createTime ? 1 : -1
}
arr.sort(sortDate)
console.log(arr);

- 倒序
function sortDate(a,b){
return a.createTime < b.createTime ? 1 : -1
}
arr.sort(sortDate)
console.log(arr);

网友评论