summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/guix-packages.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/js/guix-packages.js b/js/guix-packages.js
index 3a3518a..1f57f1e 100644
--- a/js/guix-packages.js
+++ b/js/guix-packages.js
@@ -35,6 +35,17 @@ guix.Packages = function() {
return m.request({ method: "GET", url: "packages.json" });
};
+guix.Sorter = function(field, isDescending) {
+ this.field = field;
+ this.isDescending = _.isUndefined(isDescending) ? false : isDescending;
+};
+
+guix.Sorter.prototype.sort = function(array) {
+ var result = _.sortBy(array, this.field);
+
+ return this.isDescending ? result.reverse() : result;
+};
+
guix.controller = function() {
var self = this;
@@ -43,6 +54,7 @@ guix.controller = function() {
this.currentPageIndex = 0;
this.pageSize = 20;
this.searchTerm = m.prop("");
+ this.sorter = new guix.Sorter("name");
// All packages are visible initially
this.packages.then(function(packages) {