From d447dda941b7ffe31a29ad15c8e0393d0064fcd6 Mon Sep 17 00:00:00 2001 From: Steve Purcell Date: Wed, 28 May 2014 13:49:42 +0100 Subject: [PATCH] Shortcut sorting when simply toggling the order --- html/js/melpa.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/html/js/melpa.js b/html/js/melpa.js index ee3ee0aa..eeee6909 100644 --- a/html/js/melpa.js +++ b/html/js/melpa.js @@ -92,8 +92,12 @@ } var sortKey = sortBy + "-" + sortAscending; if (packages.sortKey === sortKey) return packages; - var matched = _.sortBy(packages, function(p) { return p[sortBy](); }); - packages = savedSearches[t] = sortAscending ? matched : matched.reverse(); + 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; };