« get me outta code hell

sort: canonize sorting locale, just in case - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-02-25 06:18:37 -0400
committer(quasar) nebula <qznebula@protonmail.com>2025-02-25 06:18:37 -0400
commitb26e3d21191e501994bf8ed9acc4e67681ea569e (patch)
tree0d81533b0b13cacb811df9173fa698b2ff86f5f8
parent96f2d47b8e46c95e546e5e0335bdfaaca58309ef (diff)
sort: canonize sorting locale, just in case
-rw-r--r--src/common-util/sort.js10
-rw-r--r--src/data/things/sorting-rule.js2
2 files changed, 9 insertions, 3 deletions
diff --git a/src/common-util/sort.js b/src/common-util/sort.js
index ea1e024a..fd382033 100644
--- a/src/common-util/sort.js
+++ b/src/common-util/sort.js
@@ -3,6 +3,12 @@
 // initial sort matters! (Spoilers: If what you're doing involves any kind of
 // parallelization, it definitely matters.)
 
+// TODO: This is obviously limiting. It does describe the behavior
+// we've been *assuming* for the entire time the wiki is around,
+// but it would be nice to support sorting in different locales
+// somehow.
+export const SORTING_LOCALE = 'en';
+
 import {empty, sortMultipleArrays, unique}
   from './sugar.js';
 
@@ -17,8 +23,8 @@ export function compareCaseLessSensitive(a, b) {
   const bl = b.toLowerCase();
 
   return al === bl
-    ? a.localeCompare(b, undefined, {numeric: true})
-    : al.localeCompare(bl, undefined, {numeric: true});
+    ? a.localeCompare(b, SORTING_LOCALE, {numeric: true})
+    : al.localeCompare(bl, SORTING_LOCALE, {numeric: true});
 }
 
 // Subtract common prefixes and other characters which some people don't like
diff --git a/src/data/things/sorting-rule.js b/src/data/things/sorting-rule.js
index 0ed7fb0f..b169a541 100644
--- a/src/data/things/sorting-rule.js
+++ b/src/data/things/sorting-rule.js
@@ -264,7 +264,7 @@ export class DocumentSortingRule extends ThingSortingRule {
     rules =
       rules
         .slice()
-        .sort((a, b) => a.filename.localeCompare(b.filename));
+        .sort((a, b) => a.filename.localeCompare(b.filename, 'en'));
 
     for (const {chunk, filename} of chunkByProperties(rules, ['filename'])) {
       const initialLayout = getThingLayoutForFilename(filename, wikiData);