Sort Rows
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.
How it works
Section titled “How it works”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.
Options
Section titled “Options”Sort Criteria
Section titled “Sort Criteria”An ordered list of { column, direction } pairs. The first criterion is applied first; subsequent criteria break ties.
| Field | Type | Description |
|---|---|---|
column | string | Column 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.
Examples
Section titled “Examples”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:
| customer | order_total | tier |
|---|---|---|
| Acme Corp | 2400 | standard |
| Beta Inc | 7300 | pro |
| Gamma LLC | 1100 | standard |
| Delta Co | 12000 | pro |
Configuration: One criterion — column: order_total, direction: desc.
After:
| customer | order_total | tier |
|---|---|---|
| Delta Co | 12000 | pro |
| Beta Inc | 7300 | pro |
| Acme Corp | 2400 | standard |
| Gamma LLC | 1100 | standard |
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:
| customer | tier | amount |
|---|---|---|
| Acme Corp | standard | 250 |
| Beta Inc | pro | 750 |
| Gamma LLC | standard | 100 |
| Delta Co | pro | 1200 |
| Echo Ltd | pro | 500 |
Configuration: Two criteria — first tier ascending, then amount descending.
After:
| customer | tier | amount |
|---|---|---|
| Delta Co | pro | 1200 |
| Beta Inc | pro | 750 |
| Echo Ltd | pro | 500 |
| Acme Corp | standard | 250 |
| Gamma LLC | standard | 100 |
Empty cells sort to the end
Section titled “Empty cells sort to the end”You want to rank products by review count but rows with no reviews should not appear at the top of an ascending sort.
Before:
| product | reviews |
|---|---|
| Widget | 42 |
| Gadget | |
| Gizmo | 7 |
| Doohickey | |
| Thingamajig | 18 |
Configuration: One criterion — column: reviews, direction: asc.
After:
| product | reviews |
|---|---|
| Gizmo | 7 |
| Thingamajig | 18 |
| Widget | 42 |
| Gadget | |
| Doohickey |
Tips and Edge Cases
Section titled “Tips and Edge Cases”- 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
parseFloatconsumes only the leading numeric prefix. If both cells parse as numbers, the comparison is numeric (so"9"sorts before"10"). ButparseFloat("2025-06-30")returns2025— 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, orYYYYMMDDinteger). Seeapps/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.
Related Transforms
Section titled “Related Transforms”- 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).