Sorts the contents of a dynamic array.
SORT(array{, attr#{, value# {, sortOrder}}})
SORT(array{, attr#{, value#}}; sortOrder)
array Any DataBasic expression that evaluates to a dynamic array.
attr# Optional. The number of the attribute to sort.
value# Optional. The number of the value to sort within the specified attribute.
sortOrder Optional. Any DataBasic expression that evaluates to a string containing a combination of the following letters, which must appear in the order shown:
[A || D][L || R]
where the letters have the following meanings:
[A || D] Sort into ascending/descending order respectively.
[L || R] Sort into ASCII/numeric order respectively.
The default sort order is "AL".
The return value is a dynamic array containing the selected elements, sorted as specified and separated by attribute marks.
Note: Before sorting, all values and sub-values in the selected elements are promoted to attributes.
If attr# and/or value# are omitted, but sortOrder is included, array must be separated from sortOrder with a semicolon. If a comma is used, an error will be generated at runtime.
SORTED = SORT(UNSORTED)
Sorts the array UNSORTED into ascending ASCII order and assigns the result to the variable SORTED.
DR = SORT(X; "DR")
Sorts the array X into descending numeric order and assigns the result to the variable DR. Note the semicolon separating the two parameters; this is necessary because no attribute and value are specified.
AL3 = SORT(ARY, 3)
Sorts the third attribute of array ARY into ascending ASCII order and assigns the sorted elements to the variable AL3.