Sort Stage
The Sort stage reorders rows from a table in the pipeline context. It sorts by one or more columns with numeric/date-aware comparisons and writes the result to a target path you choose.
What the stage does
- Source / target — Read from a context field; write to the same field or a new target to keep both versions.
- Row range — Apply sorting only within a start and end row (inclusive). Rows outside the range are left as-is.
- Multi-column sorting — Add multiple sort conditions; they are applied in order (primary, secondary, etc.).
- Directions — Ascending or descending per column.
- Type-aware compare — Detects numbers and date-like strings; falls back to case-insensitive string compare.
- Array or object rows — Works on row arrays (by index) or row objects (by property name).
- Validation — Errors if the source isn’t an array; empty inputs exit early.
Configure the Sort stage
- Pick the Source field (context path of the table to sort).
- Set a Target field (defaults to source) to overwrite or branch the sorted result.
- Optionally set Start row and End row (inclusive indexes) to limit sorting to a slice of the table.
- Add sort conditions:
- Column (index for arrays, property for objects).
- Direction: Ascending or Descending.
- Click Run Stage to preview, or Run All to run the pipeline. The stage logs how many rows were sorted and writes to the target path.
Example: sort sales
Source field: sales
- Condition 1: Column 0 (Region) — Ascending
- Condition 2: Column 1 (Revenue) — Descending
- Output field:
sales_sorted
The stage sorts rows by Region, then by Revenue within each region, and writes the result to context.sales_sorted.
Tips for reliable sorting
- Normalize first: Use Transform to clean data types (e.g., parse dates/numbers) before sorting.
- Scope the range: Limit Start/End rows when testing so you don’t resort large datasets unintentionally.
- Branch outputs: Write sorted data to a new path for comparison in Visualize stages.