diff --git a/lib/models/chan.js b/lib/models/chan.js index 5c788d5..432bbbe 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); };