Sort List
Audience:
Low-code EngineersSkill Prerequisites:
Actions,Lists,Tokens
Sorts the items of a list by one property and saves the result as a new list. The source list isn't changed, unless you give the output list the same name.
The list comes from an earlier action, such as Create List from SQL or Create List from JSON.
Typical Use Cases
- Sort a list loaded from JSON, for example the response of an API, before showing or exporting it
- Put the newest or largest items first before taking the first page with Paginate List
- Process items in a set order with Execute Actions for each List Entry
Don't use it to
- Sort data you read from a database. Use
ORDER BYin the query of Create List from SQL instead. It's faster and handles several columns. - Sort by more than one property. The action takes a single property.
Related Actions
| Action Name | Description |
|---|---|
| Create List from SQL | Creates a list from the rows of a query. |
| Create List from JSON | Creates a list from a JSON array. |
| Paginate List | Takes one page of items from a list. |
| Remap List | Renames the properties of a list's items. |
| Execute Actions for each List Entry | Runs actions once for each item, in list order. |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| List Name | The name of the list to sort, for example ProductsList. The name is case-sensitive. An empty name doesn't use the listing's rows. In a listing, enter ActionGridEntry to sort the listing's records. | Yes | empty string | Yes |
| Sort Property | The property to sort by, for example Price. The name isn't case-sensitive. It must be one of the list's properties, or the action fails. | Yes | empty string | Yes |
| Sort Direction | Ascending (smallest first) or Descending (largest first). In expression mode, the value must resolve to Ascending or Descending. | Yes | Ascending | No |
| Output List Name | The name of the sorted list, for example SortedProductsList. Use the same name as List Name to replace the source list. If it's empty, nothing is created. Tokens aren't replaced here: the text is used as typed, without square brackets. | No | empty string | Yes |
Output Parameters Reference
| Output | Description |
|---|---|
List <Output List Name> | A copy of the source list's items, in sorted order, with the same properties. |
The action doesn't create a [<Output List Name>:Count] token. The number of items is the same as in the source list, so use [<List Name>:Count] if the source has one.
How values are compared
Items are compared by the value of the sort property, using the value's type:
- Text is sorted alphabetically with the rules of the current culture. Numbers stored as text are sorted as text, so
10comes before9. - Numbers and dates are sorted by value.
- Empty values (no value at all) come first in ascending order and last in descending order.
The value type depends on where the list came from. Create List from SQL keeps the column types, so number and date columns sort correctly. Create List from JSON stores every value as text, so numbers and dates are sorted as text. Listing records may hold the formatted text shown in the listing.
Items with equal values keep their original order.
Considerations
- Missing list or property. The action fails if the list doesn't exist, or if
Sort Propertyisn't one of its properties. For lists from JSON, the properties come from the first item. Use theOn Erroractions of Execute Actions to handle the error. - Every item needs the property. If an item doesn't have the sort property, the action fails.
- Mixed values fail. In lists from SQL, a
NULLin a number or date column, or a mix of numbers and text, makes the action fail. ReplaceNULLin the query, for exampleISNULL(Price, 0). - Sort before removing entries. Remove List Entries clears the list's property definitions, so sorting its result fails with the property error.
- Numbers from JSON. To sort numbers or dates from JSON, pad them to the same length, or use ISO dates such as
2026-09-27, which sort correctly as text. - Nested JSON. The sorted copy doesn't keep the JSON text of nested objects and arrays that Create List from JSON makes available in loops. The values inside them, for example
[OrdersList:Customer.Name], are kept. - Large listings. Sorting
ActionGridEntryreads every record of the listing into memory.
Examples
To understand how to use the below examples, please see Running Examples.
1. Sort products by price, highest first
This action sorts ProductsList, created by Create List from SQL, by its Price column, and saves the result as SortedProductsList. Because Price is a number column, 100 comes before 90.
{
"Title": "Sort List",
"ActionType": "OrderEntityList",
"Description": "Sort products by price",
"Parameters": {
"EntityName": "ProductsList",
"SortProperty": "Price",
"SortDirection": {
"Expression": "",
"Value": "Descending",
"IsExpression": false,
"Parameters": {}
},
"OutputEntityName": "SortedProductsList"
}
}
2. Sort a list in place, in the order the user picks
This action sorts ContactsList by LastName and replaces the list with the sorted one. The direction comes from the SortOrder token, which must be Ascending or Descending.
{
"Title": "Sort List",
"ActionType": "OrderEntityList",
"Description": "Sort contacts by last name",
"Parameters": {
"EntityName": "ContactsList",
"SortProperty": "LastName",
"SortDirection": {
"Expression": "[SortOrder]",
"Value": "",
"IsExpression": true,
"Parameters": {}
},
"OutputEntityName": "ContactsList"
}
}
Revised 09/27/2026