From be45ab45f912b237b22ffcdcaadead8673637cda Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Mon, 7 Jul 2014 23:52:45 +0200 Subject: [PATCH] Sort users --- lib/models/chan.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/models/chan.js b/lib/models/chan.js index 5c788d5e..432bbbe3 100644 --- a/lib/models/chan.js +++ b/lib/models/chan.js @@ -21,5 +21,20 @@ function Chan(attr) { } Chan.prototype.sortUsers = function() { - // .. + this.users = _.sortBy( + this.users, + function(u) { return u.name.toLowerCase(); } + ); + var modes = [ + "~", + "%", + "@", + "+", + ].reverse(); + modes.forEach(function(mode) { + this.users = _.remove( + this.users, + function(u) { return u.mode == mode; } + ).concat(this.users); + }, this); };