Skip to main content

Module sorting

Module sorting 

Source
Expand description

Configurable file sorting for mbr.

Provides multi-level sorting by any field (title, filename, date, frontmatter), with configurable order (ascending/descending) and comparison type (string/numeric).

Uses a Schwartzian transform (decorate-sort-undecorate) to pre-extract sort keys, avoiding repeated field lookups and string allocations during comparisons.

Functions§

folder_entry
Builds one subfolder entry for a section/home page listing.
folder_index_frontmatter
Frontmatter of every folder’s index note, keyed by the folder’s URL (/docs/) — the lookup folder_entry needs, built in one pass.
sort_files
Sorts files in place according to the given sort configuration.
sort_folders
Sorts subfolder entries (from folder_entry) the way the sidebar’s sortFolders() does, so a section page and the sidebar list folders in the same order.