Template functions · Lists

sort

Sort sources, JSON objects or key/value pairs.

sort "property" "asc|desc" list

Works on sources (any property, including Meta.<key>), JSON objects (by a top-level field) and the pairs returned by select (Key, Value, or Value.<field>).

Values are compared as text. Give numbers the same number of digits (05, 10) so they sort correctly. Dates in YYYY-MM-DD form sort naturally.

Example

{{ range sort "Meta.date" "desc" (sources "RelPath" "blog/*") }}
  {{ .Meta.date }}: {{ .Meta.title }}
{{ end }}

data sources filter limit offset select paginate pages page path hash json contains html js css

Edit this page · Last updated 2026-11-20