Appearance
Sort
The Sort node reorders rows by a field value, either ascending or descending. It supports both numeric and string sorting.
Configuration
| Property | Type | Default | Description |
|---|---|---|---|
field | string | -- | Required. The field name to sort by. |
direction | string | asc | Sort direction: asc (ascending) or desc (descending). |
Input
Accepts an array of rows.
Output
Returns the same rows in the new sort order.
How It Works
- If both compared values are numeric, they are sorted as numbers (float comparison).
- Otherwise, they are sorted as strings (using
strcmp).
This automatic detection means "2" sorts before "10" when both are numeric, but after it in pure string sorting.
Example Use Cases
Sort by name alphabetically
field: "name"
direction: "asc"Sort by price (highest first)
field: "price"
direction: "desc"Sort by date (newest first)
field: "created_at"
direction: "desc"Date strings in YYYY-MM-DD or YYYY-MM-DD HH:MM:SS format sort correctly as strings.
TIP
When possible, use the orderBy and order options on source nodes to sort at the database level. The Sort node is useful for re-sorting data after transforms, or sorting data from sources that don't support native ordering (like static JSON or combined datasets).