Browse Source

chore: Use localeCompare for reliable alphabetical sorting

Michael Bromley 1 week ago
parent
commit
773ab123c0
1 changed files with 2 additions and 2 deletions
  1. 2 2
      scripts/docs/typescript-docs-renderer.ts

+ 2 - 2
scripts/docs/typescript-docs-renderer.ts

@@ -135,7 +135,7 @@ export class TypescriptDocsRenderer {
 
 
                     if (allLinkCards.size > 0) {
                     if (allLinkCards.size > 0) {
                         indexFileContent += '\n';
                         indexFileContent += '\n';
-                        const sortedCards = Array.from(allLinkCards).sort();
+                        const sortedCards = Array.from(allLinkCards).sort((a, b) => a.localeCompare(b));
                         for (const href of sortedCards) {
                         for (const href of sortedCards) {
                             // Extract child name from href for title
                             // Extract child name from href for title
                             const childName = href.split('/').pop() || '';
                             const childName = href.split('/').pop() || '';
@@ -190,7 +190,7 @@ export class TypescriptDocsRenderer {
                     let indexFileContent = generateFrontMatter(sectionTitle, true);
                     let indexFileContent = generateFrontMatter(sectionTitle, true);
 
 
                     indexFileContent += '\n';
                     indexFileContent += '\n';
-                    const sortedCards = Array.from(allLinkCards).sort();
+                    const sortedCards = Array.from(allLinkCards).sort((a, b) => a.localeCompare(b));
                     for (const href of sortedCards) {
                     for (const href of sortedCards) {
                         const childName = href.split('/').pop() || '';
                         const childName = href.split('/').pop() || '';
                         const title = titleCase(childName.replace(/-/g, ' '));
                         const title = titleCase(childName.replace(/-/g, ' '));