The SORTDATA() function returns the data elements from a sort.
The SORTDATA() function is intended as an alternative to a loop containing a SORTNEXT() function where no processing of the individual items is required. It returns the data associated with sorted items as a field mark delimited dynamic array. If the sort does not include a data element, the first key value for each entry is returned.
The max.items argument limits the number of items returned. A further use of SORTDATA() will return subsequent items from the sort.