From b1642883ba4cd57e327c503ea8b5dcc2b3f5cbd2 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sat, 17 Aug 2024 09:39:55 -0400 Subject: [PATCH] Sort items alphabetically by name, with directories first --- tuftedoc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tuftedoc.py b/tuftedoc.py index e2b0ff5..deb413a 100644 --- a/tuftedoc.py +++ b/tuftedoc.py @@ -210,6 +210,7 @@ def process_directory(full_path: pathlib.Path) -> Tuple[List[FileInfo], Optional ) all_items.append(item_data) + # Sort items alphabetically by name, with directories first all_items.sort(key=lambda x: (not x.is_dir, x.name.lower())) index_file = full_path / "index.md"