SORT Function

The SORT function enables the user to sort a dynamic array, either left or right justified or into ascending or descending order. The general form of the function is similar to LOCATE( ):

Format

result=SORT(string{,attno{,valno}};sort.sequence)

Description

If attno and valno are omitted, SORT( ) sorts the entire multiattribute list stored in string.

Sorting occurs according to the sort criteria specified by sort.sequence, which may be one of these:

AL

Ascending, left justified

AR

Ascending, right justified

DL

Descending, left justified

DR

Descending, right justified

If attno is specified, the sorted MultiValues of that attribute in the string are returned. Similarly, if valno is specified, only the multi-subvalues of the specified value is sorted and returned.

SORT( ) typically executes 5 to 10 times as quickly as other sorting routines in mvBASIC, and therefore should be used whenever speed is important.

See Also

Statement and Function Reference