时间数组排序

时间数组:

var timeArr = ["2015-07-02","2016-01-01","2015-07-03","2015-12-02"]

时间数组从小到大排序:

timeArr.sort((a,b)=>{
    return parseInt(a.replace(/\D/g,''),10) - parseInt(b.replace(/\D/g,''),10)
})
conosle.log(timeArr);
//["2015-07-02","2015-07-03","2015-12-02","2016-01-01"]
posted @ 2017-09-01 11:11  枫叶布  阅读(548)  评论(0编辑  收藏  举报