Array Sort
This node reorders an array based on values.
The Array Sort node creates a sorted copy of an input array.
The Array Sort node takes an array and sorts its items based on a specific property (Key Path). It supports ascending and descending order and handles numbers and strings correctly.
| Data | Description |
|---|
| Array | The source array to sort. |
Object Options
| Data | Description |
|---|
| Key Path | The property key to sort by (e.g., "price", "date", "name"). Required for object arrays. |
Sort Options
| Data | Description |
|---|
| Ascending | Boolean. true for A-Z / 0-9. false for Z-A / 9-0. Default: true. |
Actions
| Signal | Description |
|---|
| Do | Triggers the sort operation. |
Outputs
Data
| Data | Description |
|---|
| Sorted Array | The resulting sorted array. |
Signals
| Signal | Description |
|---|
| Done | Triggered when the sort is complete. |
Usage
Use this node to organize lists for display.
Example Use Cases
- Leaderboard: Sort players by "score", Ascending =
false (highest first).
- Product List: Sort by "price", Ascending =
true (cheapest first).
- Alphabetical: Sort by "name".
Detailed Behavior
- Type Handling:
- Numbers: Sorted numerically (
1, 2, 10).
- Strings: Sorted alphabetically using locale comparison (
"a", "b", "c").
- Stability: The sort is generally stable (items with equal sort values maintain their relative order).
- New Collection: Creates a new collection; does not mutate the original array.
Troubleshooting
- Sorting Numbers as Strings: If your numbers are stored as strings ("10", "2"), they might sort alphabetically ("10", "2"). Ensure your data types are correct upstream.