正反序区别与调用处理方法中的大小写

正序:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
var dataContent = [
{
ID: "1",
hobbit: "去音乐",
sport: "在篮球",
movies: "功夫",
sender: "elson",
received: "2017-08-18 13:23:21",
sex: "man",
age: "21"
},
{
ID: "22",
hobbit: "我音乐",
sport: "怕篮球",
movies: "阿斯蒂",
sender: "neson",
received: "2017-03-18 19:23:21",
sex: "woman",
age: "22"
},
{
ID: "32",
hobbit: "人音乐",
sport: "哦篮球",
movies: "发的",
sender: "nelson",
received: "2015-08-18 13:23:21",
sex: "man",
age: "22"
},
{
ID: "14",
hobbit: "额音乐",
sport: "的篮球",
movies: "为个",
sender: "nlson",
received: "2017-01-18 13:23:21",
sex: "man",
age: "12"
},
{
ID: "5",
hobbit: "他音乐",
sport: "人篮球",
movies: "问发",
sender: "nelon",
received: "2017-03-18 13:23:21",
sex: "woman",
age: "32"
},
{
ID: "6",
hobbit: "有音乐",
sport: "打篮球",
movies: "雨天",
sender: "nson",
received: "2013-08-18 13:23:21",
sex: "man",
age: "22"
},
{
ID: "7",
hobbit: "听音乐",
sport: "打篮球",
movies: "太过分哈",
sender: "nelsn",
received: "2017-08-18 10:56:21",
sex: "man",
age: "22"
},
{
ID: "8",
hobbit: "听音乐",
sport: "打篮球",
movies: "功夫",
sender: "elon",
received: "2017-02-18 13:23:21",
sex: "man",
age: "22"
},
];

//正序
dataContent = ForwardRankingDate(dataContent, "received");
console.log(dataContent);

//封装的日期排序方法
function ForwardRankingDate(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;
}

反序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
var dataContent = [
{
ID: "1",
hobbit: "去音乐",
sport: "在篮球",
movies: "功夫",
sender: "elson",
received: "2017-08-18 13:23:21",
sex: "man",
age: "21"
},
{
ID: "22",
hobbit: "我音乐",
sport: "怕篮球",
movies: "阿斯蒂",
sender: "neson",
received: "2017-03-18 19:23:21",
sex: "woman",
age: "22"
},
{
ID: "32",
hobbit: "人音乐",
sport: "哦篮球",
movies: "发的",
sender: "nelson",
received: "2015-08-18 13:23:21",
sex: "man",
age: "22"
},
{
ID: "14",
hobbit: "额音乐",
sport: "的篮球",
movies: "为个",
sender: "nlson",
received: "2017-01-18 13:23:21",
sex: "man",
age: "12"
},
{
ID: "5",
hobbit: "他音乐",
sport: "人篮球",
movies: "问发",
sender: "nelon",
received: "2017-03-18 13:23:21",
sex: "woman",
age: "32"
},
{
ID: "6",
hobbit: "有音乐",
sport: "打篮球",
movies: "雨天",
sender: "nson",
received: "2013-08-18 13:23:21",
sex: "man",
age: "22"
},
{
ID: "7",
hobbit: "听音乐",
sport: "打篮球",
movies: "太过分哈",
sender: "nelsn",
received: "2017-08-18 10:56:21",
sex: "man",
age: "22"
},
];

//反序
dataContent = ReverseRankingDate(dataContent, "received");
console.log(dataContent);

//封装的日期排序方法
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;
}