美文网首页
javaScript sort 时间排序

javaScript sort 时间排序

作者: Enginner_XZ | 来源:发表于2020-10-08 12:37 被阅读0次
  • 原数据


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

相关文章

网友评论

      本文标题:javaScript sort 时间排序

      本文链接:https://www.haomeiwen.com/subject/uracpktx.html