Sort Items with the Sort Node in n8n
Data rarely arrives in the order you need. Product lists might come unsorted from an API, customer records might be in random order, or you might need to find the highest-rated or cheapest items first.
The Sort node reorders items based on field values. It offers three modes: Simple (sort by fields), Random (shuffle into random order), and Code (custom JavaScript logic). In this challenge, we will focus on Simple mode - the most common way to sort data.
With Simple mode, you can sort by one field or multiple fields, in ascending or descending order. When sorting by multiple fields, the first field takes priority, and subsequent fields break ties.
What you'll practice:
- Using the Sort node in Simple mode
- Sorting by multiple fields with priority
- Understanding ascending vs descending order
Your Task
- 1Copy the exercise below
- 2Paste into your n8n editor (Ctrl+V)
- 3Solve it — use hints if you get stuck
- 4Check the solution when done
Fetch products from https://dummyjson.com/products?limit=12 and sort them by:
- Category (alphabetically, A to Z)
- Price (lowest to highest, within each category)
Example product structure:
{
"id": 1,
"title": "Essence Mascara Lash Princess",
"category": "beauty",
"price": 9.99,
"rating": 4.94
}
Expected result: Products grouped by category in alphabetical order, with the cheapest products first within each category.
Get the exercise workflow
Create a free account to copy exercises into your n8n editor.