Skip to content

Commit

Permalink
Fix value sent in
Browse files Browse the repository at this point in the history
  • Loading branch information
waxxxd committed Aug 29, 2024
1 parent 40587ff commit 8b6edf8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/types/MarkdownTextRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,17 @@ export class MarkdownTextRenderer {
} else if (this.plugin.settings.sortIndexFiles === SortBy.ReverseAlphabetically) {
fileTree.sort((a, b) => b.name.localeCompare(a.name))
} else if (this.plugin.settings.sortIndexFiles === SortBy.Natural) {
fileTree.sort((a, b) => this.naturalSort(a, b))
fileTree.sort((a, b) => this.naturalSort(a.name, b.name))
} else if (this.plugin.settings.sortIndexFiles === SortBy.ReverseNatural) {
fileTree.sort((a, b) => this.naturalSort(b, a))
fileTree.sort((a, b) => this.naturalSort(b.name, a.name))
}
return fileTree
}

private naturalSort(a: string, b: string): number {
const re = /(\d+)|(\D+)/g;
const aParts = a.split(re).filter(part => part.length > 0);
const bParts = b.split(re).filter(part => part.length > 0);
const aParts = a.split(re).filter((item) => item !== undefined && item.length > 0);
const bParts = b.split(re).filter((item) => item !== undefined && item.length > 0)

for (let i = 0; i < Math.min(aParts.length, bParts.length); i++) {
const aPart = aParts[i];
Expand Down

0 comments on commit 8b6edf8

Please sign in to comment.