nœuds / builtin / datatransformation
Sort
Order the incoming items by one or more fields, or shuffle them randomly
Ce contenu n’est pas encore disponible dans votre langue.
Put your items in order by one or more fields, such as cheapest first or newest first, or shuffle them.
What it does
Section titled “What it does”Sort reorders the whole incoming list at once. No items are added or removed.
- By fields: you add sort keys under Sort By. Each key names a field, a Direction and a way to compare (Compare As). Keys apply in order: the second key only decides between items that tie on the first.
- Random (shuffle): the items are put in a random order and the sort keys are ignored.
Items that tie keep their original order. Items where the field is missing, null or empty always go last, in both directions, so empty rows never float to the top of a descending list.
When to use it
Section titled “When to use it”- Show results newest first or cheapest first before you send or save them.
- Get a real “top 5” by sorting before Limit.
- Pick which copy Remove Duplicates keeps: it keeps the first one, so sort first.
- Take a random sample: shuffle, then Limit.
Inputs and settings
Section titled “Inputs and settings”| Réglage | Type | Ce que cela fait |
|---|---|---|
| Mode | Choice | Sort by field values, or shuffle into a random order. Options: By fields, Random (shuffle). Par défaut : By fields |
| Sort By | List of entries | Fields to sort by, applied in order. |
| Sort By (each entry) › Field (obligatoire) | Text | Field to sort by. Use dots for nested fields, e.g. user.profile.name. |
| Sort By (each entry) › Direction | Choice | Options: Ascending, Descending. Par défaut : Ascending |
| Sort By (each entry) › Compare As | Choice | How values in this field are compared. Options: Automatic, Number, Text, Text (natural), Date. Par défaut : Automatic |
Compare As decides how two values are compared:
- Automatic treats values as numbers when it can, then as dates, otherwise as text in natural order.
- Text (natural) reads digits as numbers inside text, so
item 2comes beforeitem 10. - Text compares character by character, so
item 10comes beforeitem 2. Use it for codes that must sort strictly by character. - Number and Date force that reading. Use Number when prices or counts arrive as text.
Use dots for nested fields, for example price.amount. A key with an empty Field is ignored.
Outputs
Section titled “Outputs”-
Output
The same items in their new order.
Dependencies and credentials
Section titled “Dependencies and credentials”None. This node needs no connection and has no slots for other nodes.
Example workflow
Section titled “Example workflow”- HTML Extract reads a list of products with
nameandpricefrom a shop page. - Sort with two keys: Field
price, Direction Ascending, Compare As Number; then Fieldname, Direction Ascending, to break ties. - Limit with Max Items
5keeps the five cheapest. - A Slack node posts them.
Common issues
Section titled “Common issues”- The order does not change. Sort needs a list. If the previous node sends one item that holds a list in a field, split it first with Split Out. Also check that at least one key has a Field.
10comes before2. The values are compared as text. Set Compare As to Number, or Text (natural) for text with numbers inside.- Empty items sit at the bottom of a descending sort. This is on purpose: missing and empty values always go last.
- “No source node is connected to this node.” Connect the node that produces the list to Sort’s input.
Related nodes
Section titled “Related nodes”- Limit: keep the first or last few items after sorting.
- Remove Duplicates: drop copies, keeping the first.
- Split Out: turn a list field into items you can sort.