Steps
Numbers sort as text when they are strings
Prices stored as strings
"100","9","25"sorted ascending came out100, 25, 9, with a green run. The same values as real numbers sorted9, 25, 100. Values from a CSV, Google Sheets or an HTML page are usually strings. Convert them first with an Edit Fields node (type Number), or use Sort in Code mode withreturn a.json.price - b.json.price;, which coerces strings and gave9, 25, 100. When only some values were strings the order happened to be right, so the bug can hide until every value is text.Dates: ISO sorts right, dd/mm/yyyy sorts by day
ISO dates like
2026-10-24sorted correctly, newest first with descending. Day-first dates24/10/2026,03/11/2026,15/09/2026sorted ascending gave03/11, 15/09, 24/10: ordered by the day number, not the date. Convert them to ISO first with the Date & Time node (From Date Formatdd/MM/yyyy), then sort.A missing or null value scrambles the whole order
Prices
5, missing,1,nullsorted ascending came out5, missing, null, 1, with no error. One empty value is enough to break the order of everything. Remove empty items with a Filter node first, or give them a default in Edit Fields, for example{{ $json.price ?? 0 }}."Couldn't find the field": use the plain field name
Field Name is case-sensitive:
Priceon items that havepricefailed withCouldn't find the field 'Price' in the input data. Field Name also wants the name, not an expression. Dragging{{ $json.price }}into it resolves to the value, so the error readCouldn't find the field '100' in the input data. Typeprice. Nested fields work with dot notation, for examplemeta.score. An empty Field Name stops the workflow before it runs:The 'Sort' node has issues: Parameter "Field Name" is required.Sorting an array inside one item fails
Sort orders items, not the elements of an array. One item holding
{"rows":[...]}failed withCouldn't find the field 'price' in the input data. Use Split Out onrowsfirst, sort, then Aggregate back if you need one item.Text order: case, accents and numbers in names
Text sorting ignores case:
bob, Alice, carol, ZedbecameAlice, bob, carol, Zed. Accented letters go after z:Eric, Zoe, élodie, Émile. Names with numbers sort letter by letter:item1, item10, item2. For language-aware or natural order, use Code mode:return a.json.name.localeCompare(b.json.name, 'fr');for accents, orlocaleCompare(b.json.name, undefined, {numeric: true})for item2 before item10 (we did not run the numeric variant).Code mode fails silently
In Code mode the items keep their input order, with a green run, if you forget
.json(a.price - b.price) or return true or false (a.json.price > b.json.price) instead of a number. Return a negative number, zero or a positive number, and read fields througha.jsonandb.json.Top N: Sort first, then Limit
Several sort keys apply in order: team ascending then score descending gave
a/9, a/2, b/5, b/1, and booleans descending puttruefirst. The Limit node keeps the first N items by default; set Keep to Last Items for the last N. Sort then Limit 1 returned the top item (100). Limit then Sort only sorted the item that came first in the input, which is the usual top N mistake. Max Items 0 returned no items, so the next node never ran. A Max Items larger than the input passed everything with no error. Limit on one item holding an array kept the whole array: Split Out first.
What we ran
On 24 October 2026 we ran 33 executions of the Sort node v1 and the Limit node v1 on self-hosted n8n 2.43.7 with n8n execute: a Manual Trigger, a Code node with test items, the Sort or Limit node and a Code node that recorded the output. 29 runs succeeded and 4 failed. Every value below is copied from those runs.
| Setup | Result |
|---|---|
Prices as strings "100","9","25", ascending | Green run, text order: 100, 25, 9 |
| Prices as numbers, ascending / descending | 9, 25, 100 / 100, 25, 9 |
| Negative and decimal numbers | -10, -1.5, 0.3, 2 |
Strings, Code mode a.json.price - b.json.price | 9, 25, 100 |
| ISO dates, descending | Newest first, correct |
24/10/2026, 03/11/2026, 15/09/2026, ascending | 03/11, 15/09, 24/10: by day number |
bob, Alice, carol, Zed | Alice, bob, carol, Zed (case ignored) |
Zoe, Émile, Eric, élodie | Eric, Zoe, élodie, Émile (accents after z) |
item10, item2, item1 | item1, item10, item2 |
Prices 5, missing, 1, null, ascending | Green run, scrambled: 5, missing, null, 1 |
Field Name Price, items have price | Error: Couldn't find the field 'Price' in the input data |
Field Name {{ $json.price }} | Error: Couldn't find the field '100' in the input data |
One item with an array rows, Field Name price | Error: Couldn't find the field 'price' in the input data |
| Empty Field Name | Not run: The 'Sort' node has issues: Parameter "Field Name" is required. |
Nested field meta.score | Sorted correctly |
| Team ascending, then score descending | a/9, a/2, b/5, b/1 |
| Boolean field, descending | true first |
Code mode a.price - b.price (no .json) | Green run, input order unchanged |
Code mode returning a.json.price > b.json.price | Green run, input order unchanged |
| Limit, Max Items 2 / Keep Last Items | First 2 items / last 2 items |
| Sort descending, then Limit 1 | Top item 100 |
| Limit 1, then Sort | Only the first input item reaches Sort, so you get the top item only if it happened to come first |
| Limit, Max Items 0 | 0 items, next node did not run |
| Limit, Max Items 10 on 3 items | All 3 passed, no error |
Limit, Max Items as expression or string "2" | Works |
| Limit 1 on one item holding an array | Whole array kept |
Quick checklist
- Order looks random or 100 before 9? Check the values are numbers, not strings, and none is empty or null.
- Dates out of order? Convert dd/mm/yyyy to ISO before sorting.
Couldn't find the field? Plain field name, exact case, no expression, and not an array inside one item.- Code mode does nothing? Use
a.jsonand return a number. - Wrong top N? Sort before Limit.
Good to know
- Turning an array into items and back: n8n Split Out, Aggregate and Summarize. Changing a field type to Number: n8n Edit Fields (Set) node.
- Dates written day first: n8n Date & Time node. Dropping empty items: n8n Filter node. Finding new or changed rows: n8n Compare Datasets.
- Every error message we reproduced is in the n8n error message index.
What we didn't test
- The editor UI itself (we ran workflows from JSON), n8n Cloud, and the Random sort type (one run is not enough to judge it).
Start from a working agent
FAQ
Why is the n8n Sort node putting 100 before 9?
The values are strings, so they sort as text. Convert the field to Number with Edit Fields before sorting, or use Code mode with a.json.price - b.json.price.
What does "Couldn't find the field in the input data" mean in the n8n Sort node?
The Field Name does not match a top-level or dot-notation field on the items. Check the exact case, type the plain name instead of an expression, and Split Out arrays first.
How do I sort by date in n8n?
ISO dates such as 2026-10-24 sort correctly. Convert dd/MM/yyyy dates to ISO with the Date & Time node first, otherwise they are ordered by the day number.
Why does one empty value break the n8n sort order?
In our runs a single missing or null value scrambled the whole order with no error. Filter out empty items or give them a default value before the Sort node.
How do I get the top 5 items in n8n?
Sort descending, then add a Limit node with Max Items 5. Putting Limit before Sort only sorts the first items you kept.
How do I keep the last items with the n8n Limit node?
Set Keep to Last Items. The default keeps the first items.
Related guides
- n8n Split Out, Aggregate and Summarize not working: 78 runs, fixed
- n8n Edit Fields (Set) node not working: dropped fields, type errors and invalid JSON, 29 runs
- n8n MongoDB node errors: Authentication failed, Invalid JSON and query fixes, 40 runs
- n8n Compression node not working: zip, unzip, file_0 and invalid zip data, 42 runs
- n8n Google Calendar node not working: "Not a valid Google Calendar ID", OAuth2 fixes
New guides
- GitHub release notifications in Slack (any public repo, stable releases only)
- Send RSS feeds to Slack with a keyword filter (free, incoming webhook)
- Forward emails to a Slack channel (Gmail, Outlook, any IMAP), free with an incoming webhook
- n8n Google Sheets Trigger not working: not firing, activation errors and fixes