SORT-MERGE/XL Programmer's Guide (32650-90884)

Chapter 1 15
Introduction
Keys
Keys
When information is sorted or merged, keys determine the output record sequence. Keys
are defined by their beginning position, length, key type, and ordering sequence (ascending
or descending).
For example, to sort by last names with the record format below, you would specify a key
that begins in column 1 and is 20 characters long, byte (ASCII) type, and ascending
sequence.
Last Name First Name Employee Number Hire Date
Jackson, Jonathan 000006 06/06/87
0 1 2 3 4 5 6
123456789012345678901234567890123456789012345678901234567890123456789
You can specify the collating sequence, which is the order by which the keys are sorted. You
can use a predefined order, like ASCII, EBCDIC, or a Native Language, or you can define
your own collating sequence.
You may use multiple keys. The major key determines the part of the record examined first
in the sort. As Figure 1-4. shows if the major keys of two records are the same, the
secondary keys determine the new sequence of the records. If two records have the same
first keys and the same second keys, their third keys are compared to determine the
sequence. If all the key fields in two or more records are identical, the output file preserves
the order of the input records.
Figure 1-4. Key Comparing Operations