Sort list

Value resolver – Abstract

Purpose: This sorts the entries in a list provided as an input value in ascending or descending order. Hierarchical sorting criteria can optionally be defined, the value configuration of which is applied to all list entries.

images/download/attachments/169634132/image-2025-3-5_16-49-25-version-1-modificationdate-1741189765545-api-v2.png

The Sort list value resolver sorts the entries of a list present as input value, taking into account one or more hierarchical sort criteria with the following parameters:

  • The optional Compare value parameter defines a value resolver that is applied per list entry to determine the value that is decisive for sorting.

  • The Ascending option (checked by default) defines the direction of sorting. It can be unchecked if descending sorting is desired.

The return value is always a new list instance that lists all entries from the input value according to the sort order.

Special cases:

  • If the input value is 'No value' ($null), the return value is also 'No value' ($null).

  • If the input value is an empty list ([]), the return value is also an empty list ([]).

  • If the input value is a value that is not 'No value' ($null) but also not a list, then the return value is a list with this value as the only entry.

Configuration

The optional Compare value parameter can be used to define a value resolver that is applied to each entry in the input value to determine a comparison value for sorting.

  • Without a value resolver (default), the complete list entry is used as the compare value.

images/download/attachments/169634132/image-2025-3-5_16-50-6-version-1-modificationdate-1741189806387-api-v2.png

The Ascending option is checked by default, which causes sorting in ascending order according to the Compare value.

If sorting in descending order is desired, the Ascending option must be unchecked.

Initially, the configuration of the Sort list value resolver provides for a single sort criterion.

  • By clicking on the (plus) images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/add.svg icon, further sorting criteria can be added to create a hierarchy with descending priority.

  • By clicking on the images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/forbidden.svg icon (‘rubbish bin’), existing sorting criteria can be removed from a hierarchy as long as at least one sorting criterion remains.

The screenshot on the right shows a configuration with two search criteria:

  • The list is first sorted in descending order according to the value in the created field of the list entries.

  • For entries that match in this field, the lower-ranking, second search criterion applies, which refers to the namefield of the list entries and sorts in Ascending order.


images/download/attachments/169634132/image-2025-3-5_16-35-18-version-1-modificationdate-1741188917815-api-v2.png

NOTE◄ If the configuration is carried out in a context that contains a tree view, these sorting criteria can be rearranged using drag & drop to adjust their priority in the hierarchy.

  • The screenshot on the right shows a section of the tree view in which the sortItems element, which represents the list of sorting criteria, is highlighted.

  • The two child elements labelled SortedListItem represent the sorting criteria, as can be seen from their expanded structure. The order of these elements in the sortItems node can be changed using drag & drop.

images/download/attachments/169634132/image-2025-3-5_16-50-47-version-1-modificationdate-1741189847615-api-v2.png

Examples

Simple use case: Sort simple values

In the following example, a list of simple values (in JSON notation: [1,8,6,null]) is output in descending order.

Runtime example:

images/download/attachments/169634132/image-2025-3-6_10-18-8-version-1-modificationdate-1741252688329-api-v2.png

Configuration:

In the context of an Execute with event action, the list defined statically for demonstration purposes is first defined as the reference object for the following event actions, as shown on the right:

  • From the static text (see Static values) in JSON notation, a list object is created via the JSON to object value resolver.

    In the action block the Show alert (Popup) event action is executed, which defines the sorted list as the text of the Message:

    • The Sort list value resolver does not define a Compare value, so the list entries are sorted directly.

    • The Ascending option has been unchecked so that the entries are sorted in descending order.

images/download/attachments/169634132/image-2025-3-6_10-20-26-version-1-modificationdate-1741252826267-api-v2.png

Variant:

Based on the previous example, the statically defined list entries are now output in a random order.

Configuration: (As an adjustment within the previous configuration)

In the Sort list value resolver, a Compare value is now defined via the Random long value resolver. This value resolver randomly allocates a value from the value range for the Long data type, resulting in random sorting.

NOTE◄ The Ascending option can be checked or unchecked. Since the sorting is random, this affects the order of the entries in the specific case. For once, however, this has no influence on the random sorting as a whole. Effectively, the order in the return value always appears randomly.

images/download/attachments/169634132/image-2025-3-6_10-20-52-version-1-modificationdate-1741252852460-api-v2.png

Typical use case: Sort a list of objects by a specific property

Within an event handling the (stakeholders) variable refers to a list of Companies/Clients that are involved in a business object. When saving changes, the user will be informed about the companies involved.

A separate notification appears for each company involved, reflecting selected address characteristics of the company according to a uniform scheme.

Specifically, the companies are then listed in alphabetical order by the 'Name' (address.name1) property through a series of notifications of the 'Info' type.

Runtime example:

images/download/attachments/169634132/image-2025-3-5_17-3-37-version-1-modificationdate-1741190617424-api-v2.png

Configuration:

The stakeholders variable is accessed here in the context of an Execute with event action. The image to the right shows only the event actions in the action block and (at the very top) the data type of the return value of the variable: Firmenkonto[]. For event actions, a list of the companies involved is therefore available as a reference object.

  • The For each loop event action iterates across the companies involved in the input value in alphabetical order. The Resolver for entities Sort list value resolver is therefore used as the value resolver for entries:

    • In the Compare value, the 'Name' property in the company address (address.name1) is first accessed via Object property value resolver, according to which sorting is performed.

    • The concatenated Upper case value resolver ensures that the 'alphabetical order' is maintained without consideration of upper/lower case letters. Otherwise, company names in lowercase (see 'fast-or-furious Ltd.' in our example) would be displayed after all in uppercase letters.

      NOTE◄ Alternatively, a Lower case value resolver could be used here. It is exclusively a matter of equal treatment of A-Z compared to a-z.

  • Within the loop, a Show alert (Popup) event action is executed for each company account, in which selected company account data is prepared:

    • The same property that has already been sorted is used as the Title. The upper/lower case letters are retained here as maintained in the address.

    • For the Message itself, two address characteristics (city and countryCode) from the company account are combined here in context via a Template value resolver with literal characters ('/').

      NOTE◄ The same result could also be achieved by a simple Concat strings. However, as the number of properties displayed increases, preparing the data using a Template value resolver may be clearer and easier to maintain.

images/download/attachments/169634132/image-2025-3-6_10-24-8-version-1-modificationdate-1741253048411-api-v2.png

Special use case: Multi-stage sorting

The sorting of companies in the previous example is now adjusted in such a way that it is first sorted according to the country code (countryCode) and only then according to the company name.

Runtime example: (for the same list of companies involved as above)

images/download/attachments/169634132/image-2025-3-6_10-3-55-version-1-modificationdate-1741251835338-api-v2.png

Configuration:

To achieve multi-level sorting, only one additional sort criterion (per images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/add.svg ) needs to be added for the ‘Country’ (countryCode) field within the existing configuration.

NOTE◄ As the screenshot on the right shows, this should be positioned at the top of the list. However, adding images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/add.svg always creates a follow-up criterion, so that a new ‘top criterion’ can only be placed by subsequently moving it in the tree view (see ‘Configuration’) or through more complex interactions.

images/download/attachments/169634132/image-2025-3-6_10-32-45-version-1-modificationdate-1741253565212-api-v2.png

IMPORTANT◄ The Object property value resolver for the ‘Country’ (countryCode) returns a value from the dynamic enumeration for the Country, type, which is used here directly as a sort criterion.

Based on the sorting for the top criterion ‘Country’ in the specific example (DE < IE < IT), it could be assumed that the ‘Name’ (name) of the enumeration value is the deciding factor for the sorting. However, this assumption is not actually correct!

The sort order for enumeration values is regulated differently depending on the execution context (server/client):

  • In the server context, the ‘ordinal’ (Long value) from the enumeration is sorted numerically.

  • In the client context, the ‘Name’ (String value) from the enumeration is sorted alphanumerically.

For the countries referenced in the example – ‘Germany’ (DE/82), ‘Ireland’ (IE/106) and ‘Italy’ (IT/109) – the order is always the same by chance, regardless of whether you sort by ‘Name’ or ‘Ordinal’. Even the localisation would result in the same sorting by chance.

This would look different for a list with the countries ‘Germany’ (DE/28), ‘Austria’ (AT/14) and Switzerland (CH/215):

  • Sorted by ‘Ordinal’: ‘Austria’ (AT/14) < ‘Germany’ (DE/28) < Switzerland (CH/215)

  • Sorted by ‘Name’: ‘Austria’ (AT/14) < Switzerland (CH/215) < ‘Germany’ (DE/28)

  • Sorted by localisation: ‘Germany’ (DE/28) < ‘Austria’ (AT/14) < Switzerland (CH/215)

For a stable sorting with values from dynamic enumerations, it is therefore essential to explicitly decide how these values should be integrated.

The screenshot on the right shows a variant of the above configuration, in which the ‘Name’ (name) field of the Country value is read from the ‘Country’ (address.countryCode) address field of the company account for the first sort criterion.

The concatenated Upper case resolver ensures that the sorting takes place without differentiating between upper and lower case in the ‘Name’ field. The fact that all names in the enumeration are capitalised is also just a ‘fragile’ convention.

NOTE◄ In the configuration on the right, the data field path that leads directly to the name of the enumeration value has been selected in the Object property resolver:

  • address.countryCode.name

The same effect can be achieved by linking two or three Object property resolvers.

images/download/attachments/169634132/image-2025-3-6_10-30-48-version-1-modificationdate-1741253448037-api-v2.png

The variant in the screenshot on the right looks very similar to the previous one, but does not directly address the ‘Name’ (name) field of the Country value from the ‘Country’ (address.countryCode) address field.

The concatenated Upper case resolver recognises that the input value (Country type) is not a String and instead passes on its string image in upper case as a sort criterion.

  • In the server context, the ‘Name’ (name) is a string image and the sorting is the same as in the previous example.

  • In the client context, sorting is based on the localisation for the Country (for the Current locale and in capital letters), which can lead to different results.

images/download/attachments/169634132/image-2025-3-6_10-32-17-version-1-modificationdate-1741253536981-api-v2.png

The somewhat more complex configuration in the screenshot on the right aims to force a sorting according to the localisation for the Country referenced in the address for the Current locale in upper case (i.e. case-insensitive) both in the server context and in the client context:

  • The Value from localization resolver uses the relevant localisation with the following parameters:

    • Bundle: The bundle name is set here statically via the Class resolver for which the Country class is selected.

    • Resource: The resource name for the value of a dynamic enumeration is always the ‘name’ (name), which is read here using the Object property resolver.

    • The Default value for a Country that does not even have a localisation in the default language ‘English’ (en) should also be the ‘name’ (name).


images/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg CAUTIONimages/s/-95e2zf/9012/8yg2g7/_/images/icons/emoticons/warning.svg Even this substantial configuration effort compared to the initial ‘naive’ access to the countryCode field does not result with 100% certainty in identical sorting results being achieved between the server context and the client context using the Sort list.

For countries in the DACH region (as an example), the value resolver chain shown sends their default localisations for the Current locale ‘German’ (de) to the sorting. Specifically, these character strings:

  • DEUTSCHLAND

  • ÖSTERREICH

  • SCHWEIZ

However, the server and client sort the umlaut ‘Ö’ differently (ASCII code/‘OE’), so that Austria is categorised after Switzerland in the server context and between Germany and Switzerland in the client context.

images/download/attachments/169634132/image-2025-3-6_10-35-14-version-1-modificationdate-1741253713756-api-v2.png