Bootstrap

JS用时间来排序

         var dataContent = [
            {
                ID: "1",
                hobbit: "去音乐",
                sport: "在篮球",
                movies: "功夫",
                sender: "elson",
                received: "2017-01-18 11:23:23",
                sex: "man",
                 age: "21"
             },
             {
                 ID: "2",
                 hobbit: "我音乐",
                 sport: "怕篮球",
                 movies: "阿斯蒂",
                 sender: "neson",
                 received: "2017-02-18 12:24:24",
                 sex: "woman",
                 age: "22"
             },
             {
                 ID: "3",
                 hobbit: "人音乐",
                 sport: "哦篮球",
                 movies: "发的",
                 sender: "nelson",
                 received: "2017-03-18 13:23:21",
                 sex: "man",
                 age: "22"
             },
             {
                 ID: "4",
                 hobbit: "额音乐",
                 sport: "的篮球",
                 movies: "为个",
                 sender: "nlson",
                 received: "2017-04-18 14:23:21",
                 sex: "man",
                 age: "12"
             },
             {
                 ID: "5",
                 hobbit: "他音乐",
                 sport: "人篮球",
                 movies: "问发",
                 sender: "nelon",
                 received: "2017-05-18 14:23:21",
                 sex: "woman",
                 age: "32"
             },
             {
                 ID: "6",
                 hobbit: "有音乐",
                 sport: "打篮球",
                 movies: "雨天",
                 sender: "nson",
                 received: "2017-06-18 16:23:21",
                 sex: "man",
                 age: "22"
             },
         ];
 
    dataContent = ReverseRankingDate(dataContent, "received");
    console.log('结果',dataContent);
// 倒序 (顺序把大小写换一下就OK)
    function ReverseRankingDate(data, p) {
     for (i = 0; i < data.length - 1; i++) {
         for (j = 0; j < data.length - 1 - i; j++) {
             console.log(Date.parse(data[j][p]));
             if (Date.parse(data[j][p]) < Date.parse(data[j+1][p])) {
                 var temp = data[j];
                 data[j] = data[j + 1];
                 data[j + 1] = temp;
             }
         }
     }
     return data;
 }
 转自:https://www.cnblogs.com/1301694f/p/11169645.html
;