FastSort Manual

Using FastSort Commands
FastSort Manual429834-003
3-4
ASCENDING Command
SIGNED TRAILING SEPARATE | STS
specifies that the key field contains signed ASCII numeric data with the sign
character (+ or –) stored in the last byte of the field. The key length cannot be
greater than 32 bytes.
Key Fields
The order in which you enter ASCENDING and DESCENDING commands affects sort
output. The first command entered has the highest priority. SORTPROG starts sorting
the records according to key fields specified in the first ASCENDING or DESCENDING
command, then uses key fields specified in the second ASCENDING or DESCENDING
command, and so on.
If two or more records have equal values in the first key field specified in an
ASCENDING or DESCENDING command, the values of the second key field, if
specified, determine the sorted order of the records. If the records have equal values in
the second or any successive key field, the values of the next key field, if specified,
determine sorted order. If all key-field values of two or more records are equal,
SORTPROG writes or returns those records in the same order it received them.
If you specify the KEYS parameter of the TO command, the output records consist of
only key-field values. SORTPROG concatenates the values. SORTPROG considers all
records as fixed length if you specify the KEYS parameter. If a key field extends
beyond the end of a variable-length record in a structured output file, SORTPROG
pads the key values with blanks.
SORTPROG can compare a key field at the end of a short record if the record contains
the first byte of the key value. This is true unless the field type is REAL, SIGNED
TRAILING EMBEDDED, or SIGNED TRAILING SEPARATE. For comparison of these
types of data, key fields must contain complete values.
You can specify up to 63 key fields for a single sort or merge run. Fields can be
contiguous, noncontiguous, and overlapping. The minimum field length is one column
except for the REAL data type, which is either 4 or 8 bytes. The maximum field length
is the length of the record unless you otherwise define the length.
Examples
ASCENDING 72:80 STRING, 1 FOR 3 INTEGER
ASC 20 FOR 8 UPPER
ASC 1:10,5:20 ! Overlapping key fields, both STRING
ASC 1:10 UNSIGNED ! Keys of a key-sequenced file