Skip to content

sort

sort changes row order without changing values or schema. That makes it easy to miss in a DAG unless the node label says why the order matters.

Use it before report tables, deterministic previews, or downstream work where the first rows carry meaning.

FieldRequiredNotes
inputsyesExactly one upstream table.
byyesOrdered list of sort clauses. Earlier clauses are primary keys.
by[].expryesExpression used as a sort key.
by[].directionnoasc by default; set desc explicitly for descending order.
  • by is ordered: first clause is primary, second is secondary, and so on.
  • direction defaults to asc. Use desc explicitly when descending order is the intent.
  • Sort expressions can be computed keys, but simple descending order is clearer as direction: desc than as a negated expression.

default is the input rows reordered. Because shape does not change, inspect the first rows and the sort keys rather than row counts.

- id: sorted
kind: sort
inputs: [data]
by:
- { expr: "[total_bill]", direction: desc }
- { expr: "[date]", direction: asc }