From d4c122646ccd6fc989b4436e16b2dffdc931dee6 Mon Sep 17 00:00:00 2001
From: Ben Schlegel <31989404+benschlegel@users.noreply.github.com>
Date: Thu, 28 Sep 2023 15:39:44 +0000
Subject: [PATCH] fix(explorer): default sortFn implementation (#511)

---
 quartz/components/Explorer.tsx |    7 ++++++-
 docs/features/explorer.md      |    7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/docs/features/explorer.md b/docs/features/explorer.md
index 91766a9..8937b25 100644
--- a/docs/features/explorer.md
+++ b/docs/features/explorer.md
@@ -75,7 +75,12 @@
 Component.Explorer({
   sortFn: (a, b) => {
     if ((!a.file && !b.file) || (a.file && b.file)) {
-      return a.displayName.localeCompare(b.displayName)
+      // sensitivity: "base": Only strings that differ in base letters compare as unequal. Examples: a ≠ b, a = á, a = A
+      // numeric: true: Whether numeric collation should be used, such that "1" < "2" < "10"
+      return a.displayName.localeCompare(b.displayName, undefined, {
+        numeric: true,
+        sensitivity: "base",
+      })
     }
     if (a.file && !b.file) {
       return 1
diff --git a/quartz/components/Explorer.tsx b/quartz/components/Explorer.tsx
index de6b5e0..79d8781 100644
--- a/quartz/components/Explorer.tsx
+++ b/quartz/components/Explorer.tsx
@@ -15,7 +15,12 @@
   sortFn: (a, b) => {
     // Sort order: folders first, then files. Sort folders and files alphabetically
     if ((!a.file && !b.file) || (a.file && b.file)) {
-      return a.displayName.localeCompare(b.displayName)
+      // numeric: true: Whether numeric collation should be used, such that "1" < "2" < "10"
+      // sensitivity: "base": Only strings that differ in base letters compare as unequal. Examples: a ≠ b, a = á, a = A
+      return a.displayName.localeCompare(b.displayName, undefined, {
+        numeric: true,
+        sensitivity: "base",
+      })
     }
     if (a.file && !b.file) {
       return 1

--
Gitblit v1.10.0