Skip to content

Sort Rows

Transform

Reorder rows by one or more columns. Each criterion specifies a column and a direction (ascending or descending); criteria are applied in priority order, so the second criterion only breaks ties left by the first. Use it to produce deterministic outputs, group related rows together, or rank records before downstream processing.

Sort Rows reads the entire input into memory before producing output, so it requires the full dataset (it is not a streaming transform). On large inputs this means peak memory scales with row count.

Each sort criterion compares cells with a hybrid rule: if both cells parse as numbers, comparison is numeric; otherwise it falls back to locale-aware string comparison. Empty cells (empty string, null, undefined) always sort to the end regardless of direction. The sort is stable — rows that compare equal keep their original input order.

If no criteria are configured, rows pass through unchanged in input order.

Input: One tabular data connection. Output: The same columns and rows, reordered.

An ordered list of { column, direction } pairs. The first criterion is applied first; subsequent criteria break ties.

FieldTypeDescription
columnstringColumn name to sort by. Required.
direction"asc" | "desc"Ascending or descending. Required.

Defaults to an empty list (passthrough). At least one criterion must be added before the transform changes row order.

Rank customers by purchase total, highest first

Section titled “Rank customers by purchase total, highest first”

You want to rank customers from largest to smallest order amount.

Before:

customerorder_totaltier
Acme Corp2400standard
Beta Inc7300pro
Gamma LLC1100standard
Delta Co12000pro

Configuration: One criterion — column: order_total, direction: desc.

After:

customerorder_totaltier
Delta Co12000pro
Beta Inc7300pro
Acme Corp2400standard
Gamma LLC1100standard

Multi-column sort: tier first, then amount within tier

Section titled “Multi-column sort: tier first, then amount within tier”

You want pro customers grouped together, ordered by amount descending within each tier.

Before:

customertieramount
Acme Corpstandard250
Beta Incpro750
Gamma LLCstandard100
Delta Copro1200
Echo Ltdpro500

Configuration: Two criteria — first tier ascending, then amount descending.

After:

customertieramount
Delta Copro1200
Beta Incpro750
Echo Ltdpro500
Acme Corpstandard250
Gamma LLCstandard100

You want to rank products by review count but rows with no reviews should not appear at the top of an ascending sort.

Before:

productreviews
Widget42
Gadget
Gizmo7
Doohickey
Thingamajig18

Configuration: One criterion — column: reviews, direction: asc.

After:

productreviews
Gizmo7
Thingamajig18
Widget42
Gadget
Doohickey
  • Empty cells always sort to the end, regardless of direction. An ascending sort puts empty values last; a descending sort also puts them last. To put empty values first, add a Computed Column upstream that maps empty to a placeholder value, then sort on that. See apps/web/src/transforms/sort-rows/logic.ts:22-24.
  • Numeric vs string comparison is hybrid, and parseFloat consumes only the leading numeric prefix. If both cells parse as numbers, the comparison is numeric (so "9" sorts before "10"). But parseFloat("2025-06-30") returns 2025 — date strings collapse to their year prefix, which means ISO dates that share a year compare equal and stay in input order. To sort dates reliably, store them as a sortable scalar upstream (e.g. ISO year column, Unix timestamp, or YYYYMMDD integer). See apps/web/src/transforms/sort-rows/logic.ts:27-34.
  • The sort is stable. Rows that compare equal on all criteria preserve their original input order. This means appending a unique tie-breaker column is rarely necessary.
  • Filter Rows — remove rows that don’t match a condition (Sort Rows reorders, never removes).
  • Remove Duplicates — remove duplicate rows (combine with Sort Rows to choose which duplicate is kept).