PROCESIO
OverviewPlatform ActionsIntegrations & DemosMarketplaceCustom ActionsDeveloper’s Guide

Sort Data Model

Sorts a list of data models (or JSON objects) by one or more fields, each ascending or descending.

The Sort Data Model action sorts a list of data models (or JSON objects) by one or more of their fields — for example by city ascending, then by company name descending. The same list variable is used as input and output, so after the step it holds the sorted list. For simple lists of numbers or text, use Sort.

Add the action

In the Process Designer toolbox, open List and pick Sort Data Model (or type Sort Data Model in the search box). Then click Configure to open the configuration panel.

The Sort Data Model action properties with the Configure button

Inputs and outputs

FieldDirectionTypeRequiredWhat to put / what you get
List to be sortedInput and outputList of data models / JSON objectsYesThe list variable to sort. After the step, the same variable contains the sorted list.
Sort JSON configurationInputObject (JSON)YesThe ID field and the sort rules, see below.

The JSON configuration

{
  "IdField": "id",
  "Sort": [
    { "Field": "city",    "OrderType": "Asc" },
    { "Field": "company", "OrderType": "Desc" }
  ]
}
KeyRequiredMeaning
IdFieldYesA field whose value is unique for every element (for example id).
SortYesThe sort rules, applied in order: the second rule only decides between elements that are equal on the first, and so on.
Sort[].FieldYesA top-level field of the data model. Field names are case-sensitive.
Sort[].OrderTypeYesAsc (A→Z) or Desc (Z→A).

Example

List to be sorted:

[
  {"id":"a","city":"London","company":"Nevett","employees":120},
  {"id":"b","city":"Berlin","company":"Rutherford Group","employees":9},
  {"id":"c","city":"Berlin","company":"Alpha","employees":45}
]
SortResult (ids in order)
city Asc, then company Descb (Berlin, Rutherford Group), c (Berlin, Alpha), a (London)
employees Asca (120), c (45), b (9) — sorted as text, see below

Good to know

Values are always sorted as text, also numbers and dates. 120 comes before 45 and 9, because they are compared character by character. To sort numbers correctly, store them with the same number of digits (for example 009, 045, 120). Dates in the ISO format (2024-01-05) sort correctly as text.

  • Text is sorted without regard to case: A, a, b.
  • The IdField values must be unique. With two elements that share the same ID, the result contains one of them twice and loses the other.
  • Only top-level fields can be used. A nested path such as address.city and a field that does not exist do not fail the step, but the list stays in its original order.
  • A list with a single element is returned unchanged.
  • The step fails when the list is empty (The input list does not have any element!), or when IdField or Sort is missing.

On this page