SORT

SORT


SLEEP Index Level SOUNDEX
Syntax SORT( string.expression )
SORT( string.expression, ac.expression, vc.expression, sequence.expression )
Category BASIC
Type Function
Description sorts an attribute or value mark delimited string.expression in  ascending order.

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

On release 7.0 and above, a second sort function is available that works in a manner similar to the "locate" statement. On this expanded version, the user may specify in which attribute, and or value the list resides as well as the sort sequence to use.
Options
See Also statements & functions u1072 functions LOCATE
Example equ vm to char(253)
list='zebra':vm:'albatross':vm:'gooney bird':vm:'elephant'
newlist=sort(list)

The variable "newlist" contains the string:

albatross]elephant]gooney bird]zebra

The bracket ( ] ) represents a value mark.
Warnings The sort function performs a left-justified string sort only. For example:

vm = char(253)
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

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

displays:

before -1]-21]-3
after -1]-21]-3
Compatibility D3 7.0 AP
SLEEP Index Level SOUNDEX