sort() function

The sort() function sorts an attribute or value mark delimited str.exp in ascending order.

Syntax

sort(str.exp{{,ac.exp{,vc.exp}}; sequence.exp})

Parameter(s)

str.exp String, attribute or value mark to sort in sequence order.
ac.exp Attribute (or, the attribute that contains the value or subvalue) that contains the specified str.exp to sort. If ac.exp is used, the sequence.exp is required.
vc.exp Value (or, the value that contains the subvalue) that contains the specified str.exp to sort.
sequence.exp
Sequence expression.
Note: Non-integer numbers as well as mixing numeric and non-numeric data types may return unexpected results.
al Pseudo left-justified ascending sort.
ar Pseudo right-justified ascending sort.
dl Pseudo left-justified descending sort.
dr Pseudo right-justified descending sort.

Description

If the expression contains both attribute and value marks, this function replaces all marks with the type first encountered.

A second sort() function is available that works in a manner similar to the locate statement. In this expanded version, the user can specify in which attribute, and/or value the list resides as well as the sort sequence to use.

The sort() function performs a left-aligned string sort only. For example:

string = "1" : @vm : "2" : @vm : "11" : @vm : "100"
crt "before " : string
string = sort(string)
crt "after " : string

displays:

before 1]2]11]100
after 1]100]11]2

string = "-1": @vm: "-21": @vm: "-3"
crt "before ": string
string = sort(string)
crt "after ": string

displays:

before -1]-21]-3
after -1]-21]-3

Example(s)

list=’zebra’:@vm:’albatross’:@vm:’gooney bird’:@vm:’elephant’
newlist=sort(list)

The variable newlist contains the string:

albatross]elephant]gooney bird]zebra

The ] represents a value mark.