~emersion/public-inbox

gamja: sort member-list with localeCompare v2 APPLIED

Nolan Prescott: 1
 sort member-list with localeCompare

 2 files changed, 3 insertions(+), 3 deletions(-)
#838607 .build.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/public-inbox/patches/35129/mbox | git am -3
Learn more about email & git

[PATCH gamja v2] sort member-list with localeCompare Export this patch

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'.

diff --git a/components/member-list.js b/components/member-list.js
--- 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
--- a/state.js
+++ b/state.js
@@ -151,13 +151,13 @@ function isServerBuffer(buf) {
 * 0 otherwise. */
function compareBuffers(a, b) {
	if (a.server != b.server) {
		return a.server > b.server ? 1 : -1;
		return a.server.localeCompare(b.server);
	}
	if (isServerBuffer(a) != isServerBuffer(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;
}
gamja/patches/.build.yml: SUCCESS in 40s

[sort member-list with localeCompare][0] v2 from [Nolan Prescott][1]

[0]: https://lists.sr.ht/~emersion/public-inbox/patches/35129
[1]: mailto:mail@nprescott.com

✓ #838607 SUCCESS gamja/patches/.build.yml https://builds.sr.ht/~emersion/job/838607
Pushed, with a minor edit to remove the localeCompare() call for buffer
servers, because these are numerical IDs. (We should use server names
instead, but it's a TODO.)

Thanks!