removed sort methods

v1.18.x
Barış Soner Uşaklı 10 years ago
parent f9581e435d
commit 61b1251a73

@ -365,45 +365,29 @@ function sortPosts(posts, data) {
if (isNumeric) { if (isNumeric) {
if (data.sortDirection === 'desc') { if (data.sortDirection === 'desc') {
sortDescendingNumeric(posts, fields); posts.sort(function(p1, p2) {
} else { return p2[fields[0]][fields[1]] - p1[fields[0]][fields[1]];
sortAscendingNumeric(posts, fields); });
}
} else {
if (data.sortDirection === 'desc') {
sortDescendingAlpha(posts, fields);
} else { } else {
sortAscendingAlpha(posts, fields);
}
}
}
function sortAscendingNumeric(posts, fields) {
posts.sort(function(p1, p2) { posts.sort(function(p1, p2) {
return p1[fields[0]][fields[1]] - p2[fields[0]][fields[1]]; return p1[fields[0]][fields[1]] - p2[fields[0]][fields[1]];
}); });
} }
} else {
function sortDescendingNumeric(posts, fields) { if (data.sortDirection === 'desc') {
posts.sort(function(p1, p2) { posts.sort(function(p1, p2) {
return p2[fields[0]][fields[1]] - p1[fields[0]][fields[1]]; if (p1[fields[0]][fields[1]] < p2[fields[0]][fields[1]]) return -1;
if (p1[fields[0]][fields[1]] > p2[fields[0]][fields[1]]) return 1;
return 0;
}); });
} } else {
function sortAscendingAlpha(posts, fields) {
posts.sort(function(p1, p2) { posts.sort(function(p1, p2) {
if (p1[fields[0]][fields[1]] > p2[fields[0]][fields[1]]) return -1; if (p1[fields[0]][fields[1]] > p2[fields[0]][fields[1]]) return -1;
if (p1[fields[0]][fields[1]] < p2[fields[0]][fields[1]]) return 1; if (p1[fields[0]][fields[1]] < p2[fields[0]][fields[1]]) return 1;
return 0; return 0;
}); });
} }
}
function sortDescendingAlpha(posts, fields) {
posts.sort(function(p1, p2) {
if (p1[fields[0]][fields[1]] < p2[fields[0]][fields[1]]) return -1;
if (p1[fields[0]][fields[1]] > p2[fields[0]][fields[1]]) return 1;
return 0;
});
} }
function getSearchCategories(data, callback) { function getSearchCategories(data, callback) {

Loading…
Cancel
Save