From aafd8cbea5d736420a27223b2a2732be1557aa82 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 21 Jul 2024 15:07:36 +0200 Subject: [PATCH] Stop using Intl.Collator (#2542) `Intl.Collator` is not available in all environments. `localeCompare` gives the same result ## Checklist - [/] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet --- packages/cursorless-engine/src/actions/Sort.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/cursorless-engine/src/actions/Sort.ts b/packages/cursorless-engine/src/actions/Sort.ts index 8fc5f87613..fe0d167eae 100644 --- a/packages/cursorless-engine/src/actions/Sort.ts +++ b/packages/cursorless-engine/src/actions/Sort.ts @@ -45,13 +45,13 @@ abstract class SortBase implements SimpleAction { } export class Sort extends SortBase { - private collator = new Intl.Collator(undefined, { - numeric: true, - caseFirst: "upper", - }); - protected sortTexts(texts: string[]) { - return texts.sort(this.collator.compare); + return texts.sort((a, b) => + a.localeCompare(b, undefined, { + numeric: true, + caseFirst: "upper", + }), + ); } }