// guides · n8n error index

n8n Sort node not sorting correctly: numbers, dates and nulls, 33 runs

Fix the n8n Sort node: prices sorted 100, 25, 9, dd/mm dates sorted by day, item10 before item2, a null that scrambles the order, "Couldn't find the field" errors, and the Limit node top N trap. 33 real runs on n8n 2.43.7.

Updated 2026-10-24 · about 10 minutes

Still stuck after these steps? Paste your exact n8n error and we'll reproduce it and email you the fix, free →

Steps

  1. Numbers sort as text when they are strings

    Prices stored as strings "100", "9", "25" sorted ascending came out 100, 25, 9, with a green run. The same values as real numbers sorted 9, 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 with return a.json.price - b.json.price;, which coerces strings and gave 9, 25, 100. When only some values were strings the order happened to be right, so the bug can hide until every value is text.

  2. Dates: ISO sorts right, dd/mm/yyyy sorts by day

    ISO dates like 2026-10-24 sorted correctly, newest first with descending. Day-first dates 24/10/2026, 03/11/2026, 15/09/2026 sorted ascending gave 03/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 Format dd/MM/yyyy), then sort.

  3. A missing or null value scrambles the whole order

    Prices 5, missing, 1, null sorted ascending came out 5, 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 }}.

  4. "Couldn't find the field": use the plain field name

    Field Name is case-sensitive: Price on items that have price failed with Couldn'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 read Couldn't find the field '100' in the input data. Type price. Nested fields work with dot notation, for example meta.score. An empty Field Name stops the workflow before it runs: The 'Sort' node has issues: Parameter "Field Name" is required.

  5. Sorting an array inside one item fails

    Sort orders items, not the elements of an array. One item holding {"rows":[...]} failed with Couldn't find the field 'price' in the input data. Use Split Out on rows first, sort, then Aggregate back if you need one item.

  6. Text order: case, accents and numbers in names

    Text sorting ignores case: bob, Alice, carol, Zed became Alice, 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, or localeCompare(b.json.name, undefined, {numeric: true}) for item2 before item10 (we did not run the numeric variant).

  7. 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 through a.json and b.json.

  8. 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 put true first. 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.

SetupResult
Prices as strings "100","9","25", ascendingGreen run, text order: 100, 25, 9
Prices as numbers, ascending / descending9, 25, 100 / 100, 25, 9
Negative and decimal numbers-10, -1.5, 0.3, 2
Strings, Code mode a.json.price - b.json.price9, 25, 100
ISO dates, descendingNewest first, correct
24/10/2026, 03/11/2026, 15/09/2026, ascending03/11, 15/09, 24/10: by day number
bob, Alice, carol, ZedAlice, bob, carol, Zed (case ignored)
Zoe, Émile, Eric, élodieEric, Zoe, élodie, Émile (accents after z)
item10, item2, item1item1, item10, item2
Prices 5, missing, 1, null, ascendingGreen run, scrambled: 5, missing, null, 1
Field Name Price, items have priceError: 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 priceError: Couldn't find the field 'price' in the input data
Empty Field NameNot run: The 'Sort' node has issues: Parameter "Field Name" is required.
Nested field meta.scoreSorted correctly
Team ascending, then score descendinga/9, a/2, b/5, b/1
Boolean field, descendingtrue first
Code mode a.price - b.price (no .json)Green run, input order unchanged
Code mode returning a.json.price > b.json.priceGreen run, input order unchanged
Limit, Max Items 2 / Keep Last ItemsFirst 2 items / last 2 items
Sort descending, then Limit 1Top item 100
Limit 1, then SortOnly the first input item reaches Sort, so you get the top item only if it happened to come first
Limit, Max Items 00 items, next node did not run
Limit, Max Items 10 on 3 itemsAll 3 passed, no error
Limit, Max Items as expression or string "2"Works
Limit 1 on one item holding an arrayWhole array kept

Quick checklist

Good to know

What we didn't test

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

New guides

Still stuck on your n8n error?

Paste the exact error and say what the workflow should do. We reproduce it on a real n8n install and email you the fix or a working workflow, usually within 24h. Free while we're in beta.

We'll only email you about your error and TaskToAgent.