forked from huanhuan1989/javascript-jQuery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJson 数组排序
33 lines (27 loc) · 961 Bytes
/
Json 数组排序
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
/**
* jQuery.hhNewSilder 滚动图片插件
* User: huanhuan
* QQ: 651471385
* Email: [email protected]
* 微博: huanhuan的天使
* Date: 13-7-4
* Time: 下午5:20
* Dependence jquery-1.7.2.min.js
*/
/*********************************************Json 数组排序 *********************************************/
function PlayDesc(json,desc,type){
if(json){
if(desc == "desc" && type == "takeMath"){
return json.sort(function(a,b){return a.takeMath<b.takeMath?1:-1});
};
if(desc == "asc" && json != "takeMath"){
return json.sort(function(a,b){return a.takeMath>b.takeMath?1:-1});
};
if(desc == "desc" && type == "hostLevel"){
return json.sort(function(a,b){return a.hostLevel<b.hostLevel?1:-1});
};
if(desc == "asc" && json != "hostLevel"){
return json.sort(function(a,b){return a.hostLevel>b.hostLevel?1:-1});
};
}
};