~emersion/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH gamja v2] sort member-list with localeCompare

Details
Message ID
<0ea100293f0fb5617311.1662347490@freefall>
DKIM signature
pass
Download raw message
Patch: +3 -3
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] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CMO50QUN91YU.2G2C51C0JNA2A@cirno>
In-Reply-To
<0ea100293f0fb5617311.1662347490@freefall> (view parent)
DKIM signature
missing
Download raw message
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]: mail@nprescott.com

✓ #838607 SUCCESS gamja/patches/.build.yml https://builds.sr.ht/~emersion/job/838607
Details
Message ID
<i4SS84Hx7Wpx9D8itRcv43P0CiZ1qXVuKc9AiTVNlMy58Xwt1PgEuWrkA6yAZaU76jmd0Ipd6rybtNus26UpIn7BKB4enoWnkOy--Fr_zTM=@emersion.fr>
In-Reply-To
<0ea100293f0fb5617311.1662347490@freefall> (view parent)
DKIM signature
pass
Download raw message
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!
Reply to thread Export thread (mbox)