对后端返回的时间进行升序的排序

other.sort(function(a,b){
let startTime=a.time.replace(/\-/g, '/')
let endstTime=b.time.replace(/\-/g, '/')

return Date.parse(startTime) - Date.parse(endstTime);//时间正序
})





时间格式:[
{'time':'2018-9-10 0-0-0','first':'page'},
{'time':'2018-9-10 0-0-0','first':'page'},
{'time':'2018-9-10 0-0-0','first':'page'},
{'time':'2018-9-10 0-0-0','first':'page'}




]
posted @ 2018-09-19 18:02  又回到了起点  阅读(413)  评论(0编辑  收藏  举报