Sort
Description
Section titled “Description”The Sort node orders the elements of an array by a given field, in ascending or descending order. It lets you force the comparison type (number or text) or let the node detect it automatically.
It is equivalent to n8n’s Sort node.
If no source is provided, the node operates on the array received in the previous node’s data. When data is not an array but contains an items or data property that is one, the node uses it automatically. If the field is left empty, elements are sorted by their own value (useful for arrays of simple values).
Configuration
Section titled “Configuration”Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
| source | text | No | Dot-notation path to the array within data. Empty = uses data directly. Example: items, result.rows |
| field | text | No | Field to sort by (dot-notation within each item). Empty = sorts by the item value itself |
| order | select | No | asc (default): ascending. desc: descending |
| type | select | No | auto (default): detects the type. number: compares as a number. string: compares as text |
Output
Section titled “Output”The node returns the sorted array directly (compatible with other nodes that expect an array):
[ { "name": "T-shirt", "price": 12 }, { "name": "Pants", "price": 30 }, { "name": "Coat", "price": 80 }]If the input is not an array (and has no items/data array), the node returns an error asking you to set source or connect a node that returns an array.
Usage Examples
Section titled “Usage Examples”Sort products by price ascending
Section titled “Sort products by price ascending”{ "label": "Cheapest first", "field": "price", "order": "asc", "type": "number"}Sort by name alphabetically
Section titled “Sort by name alphabetically”{ "label": "Alphabetical order", "field": "name", "order": "asc", "type": "string"}Sort a nested field descending
Section titled “Sort a nested field descending”{ "label": "Highest score", "source": "result.rows", "field": "stats.score", "order": "desc", "type": "number"}Sorts the result.rows array by stats.score from highest to lowest.
- With
type: auto, the comparison respects the native type of the values (numbers, strings, ISO dates as text) - The
sourcefield supports dynamic and cross-node variables:{{@NodeName.field}},{{#N.field}} - The node does not mutate the input array: it returns a sorted copy
- Does not require credentials