Sorting Notes

Manual sorting#

You can sort notes by right-clicking the parent note in the Note Tree and selecting Advanced -> Sort notes by ... This will sort existing notes, but will not automatically sort future notes added to this parent note.

The sorting dialog allows:

  • Sorting by title, creation or modification date, or by the value of a label on the child notes.
  • Sorting by several such criteria in turn, each ascending or descending: the next level only decides between notes the previous ones left equal.
  • Ensuring folders are displayed at the top.
  • Natural sort, based on the sorting rules of a particular language.

Automatic/Permanent Sorting#

Child notes can be automatically sorted by attaching specific labels to the parent note:

LabelDescription
#sorted

Keeps child notes sorted by title alphabetically.

When given a value, it will sort by other criteria instead: a comma-separated list of levels, each title, dateCreated, dateModified or the name of a label on the child notes, optionally followed by asc or desc, as in a search's orderBy. For example #sorted="priority desc, dueDate" sorts by priority, highest first, and notes of equal priority by due date. A child note without a level's label sorts after every child that has it, whichever direction the level runs in. When neither note has the label, the next level decides.

#sortDirection

If sorted is applied, specifies the direction of the sort:

  • ASC, ascending (default)
  • DESC, descending

A level of sorted followed by its own asc or desc keeps that direction regardless.

#sortFoldersFirstIf sorted is applied, folders (notes with children) will be sorted as a group at the top (at the bottom when #sortDirection is desc), and the rest will be sorted.
#sortNaturalSort numbers naturally instead of alphabetically, so 2 comes before 10.
#sortLocaleThe language code driving the natural sort (e.g. zh-CN, de). Only meaningful together with #sortNatural.
#topIf sorted is applied to the parent note, keeps given note on top in its parent.
#bottomIf sorted is applied to the parent note, keeps given note on bottom in its parent.

Sorting is done by comparing note properties or specific labels on child notes. There are four sorting levels, with the first having the highest priority. Lower priority levels are applied only if higher priority comparisons result in equality.

  1. Top Label Sorting: Child notes with the #top label will appear at the top of the folder.
  2. Bottom Label Sorting: (Introduced in Trilium 0.62) Child notes with the #bottom label will appear at the bottom of the folder.
  3. Property/Label-Based Sorting: Sorting is based on the parent note's #sorted label:
    • Default Sorting: If #sorted has no value, notes are sorted alphabetically.
    • Property Sorting: If #sorted is set to title, dateModified, or dateCreated, notes are sorted based on the specified property.
    • Label Sorting: If #sorted has any other value, this value is treated as the name of a child note's label, and sorting is based on the values of this label. For example, setting #sorted=myOrder on the parent note and using #myOrder=001, #myOrder=002, etc., on child notes.
    • Multi-Level Sorting: Several of the above can be combined, separated by commas; each level is applied only where the previous ones are equal. Every level can carry its own direction as a word after the name, asc or desc, otherwise it follows #sortDirection. For example #sorted="priority desc, area, dateCreated" sorts by priority, highest first, then by area, then by creation date.
  4. Alphabetical Sorting: Used as a last resort when other criteria result in equality.

All comparisons are made string-wise (e.g., "1" < "2" or "2020-10-10" < "2021-01-15", but also "2" > "10").