PluginList sort control block
Setting Sort Mode
Please be warned that sorting is normally based on string. If you are trying to sort by numbers, make sure all your numbers are of the same number of digits. Otherwise 2 will be larger than 12 if doing a string sort.
{sort mode="tracker_field_example_asc"} {sort mode="tracker_field_example_desc"}
{sort mode="title_asc"}
If you want to do a numeric sort (such that 12 is larger then 2, use the following instead:
{sort mode="tracker_field_ticketNumber_nasc"} {sort mode="tracker_field_ticketNumber_ndesc"}
{sort mode="modification_date_ndesc"}
In the example above modification_date is used as the sort parameter - the list of other generic parameters that might be used to 'sort' and are available from Unified search are shown here.
There is also a way to simulate random results when showing a short list. This is of course not compatible with pagination. You have to specify a list of sort modes on irrelevant fields to choose randomly from, for example:
{sort mode="randommode" modes="title_asc,tracker_field_example_asc,tracker_field_ticketNumber_nasc, modification_date_nasc"}
You can further select the results that are going to be return by using return_only, for example:
{sort mode="tracker_field_ticketNumber_nasc" return_only="2,1,3"}
Starting with 19.1 you can use scripted sort orders on Elasticsearch, as described here for example:
{sort mode="script" source="Math.abs(new Date().getTime() - doc['date'].date.getMillis() )" order="asc"}