我是靠谱客的博主 大意睫毛,最近开发中收集的这篇文章主要介绍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

最后

以上就是大意睫毛为你收集整理的JS用时间来排序的全部内容,希望文章能够帮你解决JS用时间来排序所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(67)

评论列表共有 0 条评论

立即
投稿
返回
顶部