This function returns a result sequence from sorting a sequence of scalar-type values (Boolean, Number, String, Date, Time or Date-time).
Sorting can be in ascending or descending order. The sequence must contain values of the same type.
When the sequence values are String type, lexicographic sorting is applied.
NB:
Some differences in relation to the FreeMarker "built-in" "sort" function (click here for more details) applied to a ([?]?sort) sequence:
- The obtained result is identical for Boolean/Number/Date/Time/Date-time types. For the String type, the FreeMarker "sort" function applies sorting using a collation,
- The "sort" function cannot sort in descending order: the only solution is to use the FreeMarker "reverse" ([?]?sort?reverse) function, but the original order of equal values is not respected.
Parameters
Boolean/Number/String/Date/Time/Date-time sequence |
seqValues |
Sequence of values to sort |
Mandatory |
Boolean |
ascendingOrder |
"true" for an ascending sort, "false" for a descending sort |
Optional. The default value is "true" |
For example
<#assign seqObj = ["whale", "Barbara", "zeppelin", "aardvark", "beetroot" ]> <#-- Ascending order --> <#list hardisCore.lexicographicSort(seqObj) as aVal> - ${aVal} </#list>
The output is:
- aardvark
- Barbara
- beetroot
- whale
- zeppelin ↑ Top of page