Skip to content

Commit 55d556a

Browse files
authored
Update README.md
1 parent 064dc53 commit 55d556a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const arr = [
5858

5959
console.log('native compare', [...arr].sort()); // [ 'c', '𝖺', 'b' ]
6060
console.log('locale compare', [...arr].sort((a, b) => a.localeCompare(b))); // [ '𝖺', 'b', 'c' ]
61+
console.log('null locale compare', [...arr].sort(new Intl.Collator('zxx').compare)); // [ '𝖺', 'b', 'c' ]
6162
console.log('codepoint compare', [...arr].sort(String.codePointCompare)); // [ 'c', 'b', '𝖺' ]
6263
```
6364

@@ -95,13 +96,13 @@ function codePointCompare(left, right) {
9596
```
9697
</details>
9798

98-
### A "locale-less" collation
99+
### Null locale collation
99100

100-
There are already alternative comparators in the language, e.g. `String.prototype.localeCompare` or `Intl.Collator.prototype.compare`. While these operate on codepoints, they take into consideration the locale and collapse characters in the same equivalence class.
101+
There are already alternative comparators in the language, e.g. `String.prototype.localeCompare` or `Intl.Collator.prototype.compare`. While these operate on codepoints, they take into consideration the locale and collapse characters in the same equivalence class. This is also the case for the `zxx` "locale" in the [Stable Formatting proposal](https://github.com/tc39/proposal-stable-formatting).
101102

102-
We could imagine a collation that does not perform any locale specific logic, and simply enables comparing strings by their Unicode codepoints.
103+
While we could imagine a collation option for a null locale that does not perform any equivalence class or grapheme logic, and simply enables comparing strings by their Unicode codepoints, this seems to [go counter](https://github.com/tc39/proposal-stable-formatting/issues/13) to the core of Intl.
103104

104-
However `Intl` is a normative optional part of the spec and this would require JS engines that opt-out to implement enough of `Intl` just to offer a comparison that is agnostic of Internationalization concerns.
105+
Furthermore `Intl` is a normative optional part of the spec and this would require JS engines that opt-out to implement enough of `Intl` just to offer a comparison that is agnostic of Internationalization concerns.
105106

106107
## Q&A
107108

0 commit comments

Comments
 (0)