You have been redirected from an outdated version of the article. Below is the content available on this topic. To view the old article click here.

sort()

Usage

sort(collection, propertyKey[, sortDescending = false])

Description
Sorts the given collection according to the given property key and returns the result in a new collection. The optional parameter sortDescending is a boolean flag that indicates whether the sort order is ascending (default) or descending. This method is often used in conjunction with find().

The sort() and find() functions are often used in repeater elements in a function query, see Repeater Elements.

Parameters

Name Type Description
collection Collection The collection to be sorted
propertyKey String The name of the property
sortDescending Boolean Sort descending, if true. (optional) (default: false)

Example

${sort(find('User'))}

results in

[f1296679173b49f894f125056aecf4b5, 1224b74c018e4adf9cd6f5c07393f369, c3fe6646c03e4f62a8f31177fa979fd6]

Search results for "sort()"

sort()

Sorts the given collection according to the given property key and returns the result in a new collection. The optional parameter sortDescending is a boolean flag that indicates whether the sort order is ascending (default) or descending. This method is often used in conjunction with find().
The sort() and find() functions are often used in repeater elements in a function query, see Repeater Elements.
Parameters

Name Type Description
collection Collection The collection to be sorted
propertyKey String The name of the property
sortDescending Boolean Sort descending, if true. (optional) (default: false)
sort(collection, propertyKey[, sortDescending = false])

Dynamic Content / Repeater

The result returned by the find() function is not sorted, so in order to get a sorted project list, we need to add the system function sort() which requires two parameters: A a collection and the name of a property to sort by. Modify the function query of the repeater element as follows:

Scripting Migration

Here the $.sort() function is used to sort the nodes fetched via regular find and is not used within the find() function itself. Nothing has to be changed here!

Only occurrences which are used in advanced find need to be prefixed. Some of those predicates also exist as regular functions ($.sort(), $.empty(), …) or keywords ($.page).