From a88cbef331c89d21bc878e31c0e2976d27ce5d81 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 14 May 2018 16:22:28 +0100 Subject: [PATCH] tidy and switch to lexicographic sorting Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/rooms/RoomSettings.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index f1aba322e2..059e07ffdb 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -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 =