tidy and switch to lexicographic sorting

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2018-05-14 16:22:28 +01:00
parent 06e1acdf04
commit a88cbef331
No known key found for this signature in database
GPG key ID: 3F879DA5AD802A5E

View file

@ -719,8 +719,14 @@ module.exports = React.createClass({
}
});
privilegedUsers.sort((a, b) => userLevels[b.key] - userLevels[a.key]);
mutedUsers.sort((a, b) => userLevels[a.key] - userLevels[b.key]);
// comparator for sorting PL users lexicographically on PL descending, MXID ascending. (case-insensitive)
const comparator = (a, b) => {
const plDiff = userLevels[b.key] - userLevels[a.key];
return plDiff !== 0 ? plDiff : a.key.toLocaleLowerCase().localeCompare(b.key.toLocaleLowerCase());
};
privilegedUsers.sort(comparator);
mutedUsers.sort(comparator);
if (privilegedUsers.length) {
privilegedUsersSection =