# SORT

Syntax:

Then: sortN = m
Then: sortN(l,t,o) = m
Then: sortN(l,t,o) = exp

where: "N" is a number from 1 to 8 (to match the break positions on the output format.)
"m" is the field (real, dummy, or lookup) to sort on
"l" is the field length
"t" is the field's edit type
"o" is either A for ascending or D for descending (A is the default)
"exp" can be any expression

Without stated attributes, the dummy sort key takes on the attributes of the result of the expression. In other words, if the result of the expression is a 12-character number, the sort key is a 12-character numeric field. Just make sure that the edit types are compatible.

SORT can only be used on sort/selection processing tables.

The SORT command cannot be used to override the number of sort levels, only the sort keys.

SORT can only be used to override a sort key that HAS a sort key that has already been defined on the output format.

Version Ref: 3.x

Description:

Sorts output during SORT/SELECTION processing phase. (-v processing table). SORT lets you create customized and conditional sort keys from the sort/selection processing table. SORT will override sort keys (but not subtotal or total breaks) defined for an output format through Define Output..

Examples:

To sort in ascending order, based on a number that has a related name in another file, you can do a lookup to the other file and sort by that name. First, do the lookup on the other file (cust), and then specify the sort as follows:

Then: sort1(5,*,a)=cust(1)