Shortcut sorting when simply toggling the order

This commit is contained in:
Steve Purcell 2014-05-28 13:49:42 +01:00
parent 70f2ea74a9
commit d447dda941

View file

@ -92,8 +92,12 @@
}
var sortKey = sortBy + "-" + sortAscending;
if (packages.sortKey === sortKey) return packages;
if (packages.sortKey === sortBy + "-" + !sortAscending) {
packages = packages.reverse();
} else {
var matched = _.sortBy(packages, function(p) { return p[sortBy](); });
packages = savedSearches[t] = sortAscending ? matched : matched.reverse();
}
packages.sortKey = sortKey;
return packages;
};