# todo.sort Sorts todos for a list view by one key, with fixed tie-breakers so the order never jumps around between renders. Built from stable collections.sort-by passes, from the least to the most significant key, then mapped back to the original todos. | key | primary | ties, always ascending | | --- | --- | --- | | `manual` | `order` | creation time, then input order | | `due` | due date | priority high to none, then `order` | | `priority` | none 0, low 1, medium 2, high 3 (`desc` is high first) | due date, then `order` | | `created` | `createdAt` | `order` | | `title` | title with A-Z folded to a-z, then code-point order | `order` | - `direction` flips the primary key only. Todos with no due date are last in both directions, in the `due` sort and as a tie-breaker, because a descending due list should start with the latest real date, not the undated. - Anything still tied keeps its input order. - Creation times are compared as instants, not raw text: `…09:00:00Z` sorts before `…09:00:00.5Z`, which plain string comparison gets backwards (`.` comes before `Z`). The `manual` and `created` sorts therefore need every `createdAt` to be a UTC timestamp and fail loudly otherwise; the `due` and `priority` sorts need a known priority. The other sorts do not look at those fields. - Title case folding is ASCII only (collections.search-text's `foldAscii`), so "apple" and "Banana" sort as a person expects, identically in every language; accented letters sort after z by code point. - An unknown key or direction is an error.