我有一个JSON:排序的对象数组由不同的项目
[{
"title": "title you desire",
"url" : "thisistheurl.com",
"status" : "Downloaded"
},{
"title": "title you desire",
"url" : "thisistheurl.com",
"status" : "Downloaded"
},{
"title": "title you desire",
"url" : "thisistheurl.com",
"status" : "Not downloaded"
}]
我有这个功能按标题排序:
array.sort(function (a, b) {
var nameA = a.status,
nameB = b.status;
if (nameA < nameB) //sort string ascending
return -1;
if (nameA > nameB)
return 1;
return 0; //default return value (no sorting)
});
有没有办法通过双方的地位和头衔订购?因此,状态为“已下载”的所有人都按照标题进行分组和排序,然后按“未下载”并按标题排序。我也想“下载”成为第一个分隔线。
您能否提供您想要的排序样本? ? – 2015-04-06 03:01:07