Sort lists with localeCompare

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'.
This commit is contained in:
Nolan Prescott 2022-09-04 23:11:30 -04:00 committed by Simon Ser
parent a2d2a11d44
commit 096fcbf829
2 changed files with 2 additions and 2 deletions

View file

@ -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 {

View file

@ -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;
}