SysStemSort

                               +-A-+           +-C-+        +-1-----+
>>-SysStemSort--(--stem--,--"--+-D-+--"--,--"--+-I-+--"--,--+-start-+-->

              +-1--------+
>--,--end--,--+-firstcol-+--,--lastcol--)-----------------------------><

Sorts all or the specified items in the stem. The items can be sorted in ascending or descending order and the case of the strings being compared can be respected or ignored. Sorting can be further narrowed by specifying the first and last item to be sorted or the columns used as sort keys. Because the sort uses a quick-sort algorithm, the order of sorted items according to the sort key is undetermined.

This function operates only on stems that specify the number of items in stem.0 and all items must be numbered from 1 to n without omitting an index. A value of 0 in stem.0 is also valid but no sort will be performed.

Parameters:

stem

The name of the stem to be sorted.

order

Either "A" for ascending or "D" for descending. The default is "A".

type

The type of comparison: either "C" for case or "I" for ignore. The default is "C".

start

The index at which the sort is to start. The default is 1.

end

The index at which the sort is to end. The default is the last item.

firstcol

The first column to be used as sort key. The default is 1.

lastcol

The last column to be used as sort key. The default is the last column.

Return codes:

0

The sort was successful.

-1

The sort failed.

Example:

/* sort all elements descending, use cols 5 to 10 as key */
Call SysStemSort "MyStem.", "D", , , ,5, 10

/* sort all elements ascending, ignore the case */
Call SysStemSort "MyStem.", "A", "I"

/* sort elements 10 to 20 ascending, use cols 1 to 10 as key */
Call SysStemSort "MyStem.", , ,10, 20, 1, 10