From 096fcbf8296c90638cc2a49c92ed50d8602976fa Mon Sep 17 00:00:00 2001 From: Nolan Prescott Date: Sun, 4 Sep 2022 23:11:30 -0400 Subject: [PATCH] Sort lists with localeCompare MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The difference in case sensitivity is the most obvious change with servers like soju that support CASEMAPPING ascii and rfc1459. Currently the list: 'Alpha', 'aardvark', 'Charlie', 'comma' currently sorts to: 'Alpha', 'Charlie', 'aardvark', 'comma' with this change it will instead become: 'aardvark', 'Alpha', 'Charlie', 'comma' If something like RFC 7613 gets broader support then there are a few more differences for a list like: 'éclair', 'ecstatic, 'aardvark', 'zed', 'Gamma' currently sorts to: 'Gamma', 'aardvark', 'ecstatic', 'zed', 'éclair' with this patch would instead sort to: 'aardvark', 'éclair', 'ecstatic', 'Gamma', 'zed' The above examples were run with a locale unspecified which fell back to my browser/host default of 'en'. --- components/member-list.js | 2 +- state.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/member-list.js b/components/member-list.js index 07ff67d..70847cf 100644 --- a/components/member-list.js +++ b/components/member-list.js @@ -101,7 +101,7 @@ function sortMembers(a, b) { return i - j; } - return nickA < nickB ? -1 : 1; + return nickA.localeCompare(nickB); } export default class MemberList extends Component { diff --git a/state.js b/state.js index 6c526cb..de52790 100644 --- a/state.js +++ b/state.js @@ -157,7 +157,7 @@ function compareBuffers(a, b) { return isServerBuffer(b) ? 1 : -1; } if (a.name != b.name) { - return a.name > b.name ? 1 : -1; + return a.name.localeCompare(b.name); } return 0; }