파일 및 디렉터리 목록을 정렬할 때 자연 정렬을 사용하도록 변경

This commit is contained in:
static
2025-01-18 16:45:07 +09:00
parent 2b303f9197
commit 2af3caf3b9
2 changed files with 4 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="ko">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />

View File

@@ -5,8 +5,10 @@ export enum SortBy {
type SortFunc = (a?: string, b?: string) => number;
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" });
const sortByNameAsc: SortFunc = (a, b) => {
if (a && b) return a.localeCompare(b);
if (a && b) return collator.compare(a, b);
if (a) return -1;
if (b) return 1;
return 0;