SORT
The SORT command sorts specified records of the edit data set based on the contents of as many as five sort-fields. Use the SORT command without a parameter to sort all records in the edit data set in ascending sequence according to the data within the edit bounds. Refer to BOUNDS (BNDS, BND) for more information on setting and displaying the edit bounds. SORT is valid for non-load library member lists.
The command is available in the Browse and Edit functions in Character, Formatted, Unformatted, and Vertical Formatted modes.
lrange
Confines the sorting operation to a specified line range (records). The line range is specified with two line labels. Use any combination of user-defined labels, system labels, or line numbers (prefixed by a period). The two labels may be listed in either order. File-AID considers the beginning of the line range to be the label occurring first in the data set. Specifying only one line label confines the sorting process to the specified line. However, sorting a single line has no effect on the edit data set.
X, NX
Confines the scope of the SORT command to excluded (X) or nonexcluded (NX) lines. If the lrange parameter is also specified, only excluded or nonexcluded lines within the specified line range are sorted.
Lines are excluded using the EXCLUDE primary command or the X (exclude) line command. Excluding lines divides the edit data set into two subsets, either of which may be processed separately by the SORT command.
sort-field
Specifies from one to five sort fields. If no sort-field parameters are specified, the data within the edit bounds is used and the data is sorted in ascending sequence. The following table lists the messages that apply to the sort-field parameter.
Messages for the Sort-field Parameter
Message | Reason |
---|---|
N RECORDS SORTED | Successful sort |
INVALID SORT FIELD | Col1 is greater than col2 |
SORT FIELDS INCOMPLETE | Odd number of sort fields is specified |
SORT FIELDS INVALID | Column number greater than the logical record length is specified |
SORT FIELDS OVERLAP | Multiple sort-fields overlap |
SORT FIELDS AMBIGUOUS | A and D parameters are improperly located |
KEYS NOT SUPPORTED | Key used when nonkeyed data set is being edited |
KEY
Used as one of the five sort fields when editing a keyed data set, RRDS or BDAM data set. Specifying KEY is equivalent to specifying the two-column numbers delimiting the record key. The letters A or D may not be used to define the sorting sequence with KEY because the sort is always in ascending sequence. RRDS and BDAM records are sorted in RRN (or RBN for BDAM) order.
If other sort-field parameters are specified along with KEY, they cannot overlap the key field. The remaining sort-field parameters may also be modified by the A or D parameters.
col1, col2
Specifies column numbers for each sort-field parameter. The two column numbers must be listed together; the second column number of each pair must be greater than or equal to the first column number.
If a specified sort field extends beyond the end of a variable-length record, that record is sorted as if the columns beyond the end of the record contained null characters (hex 00). If multiple sort-field parameters are specified, they must not overlap.
/field-name, /field-number
The /field-name parameter specifies the data name given to the field in the record layout. The /field-number parameter specifies the number generated by File-AID for each data name in the record layout.
The /field-name or /field-number parameter must be prefixed by a slash (/) to distinguish it from val1 or column range (col1 and col2) parameters. A field name can be fully qualified, partially qualified, or unqualified, but it must be unique. Each unique word of the field name may be abbreviated starting with the first letter. If an abbreviated field name is used, it must be unique. Use a period to delimit levels of qualified names. If several maps are loaded, it may be necessary to include the member name or the 01-level name to uniquely identify a field. If so, precede the field name with the member name and/or 01-level name, also delimited with periods. Specify either a /field-name or /field-number parameter when the VALID/INVALID parameter is used.
A field name value that matches more than one field name in the record produces the message: AMBIGUOUS FIELD NAME. A field name value that does not match any layout field produces the message: FIELD NAME NOT FOUND.
File-AID pads the search string with trailing blanks to match the field length of the specified field name or field number. If a record layout was not entered on the Edit screen, specifying a /field-name or /field-number produces the message: FIELD UNDEFINED - NO MAP.
Use of the /field-name, /field-number parameters is mutually exclusive with use of the col1, col2 parameters.
A (default), D
Specifies ascending (A) or descending (D) order for the sort-field parameter. If an A or D parameter is specified with any sort-field parameter, all other sort-field parameters must be accompanied by one of the two letters. List the A or D before or after the corresponding column pair, not between col1 and col2.
Guidelines
All sorting performed by the SORT command is based on left-to-right (byte-by-byte) data comparisons using the EBCDIC or Unicode UTF-16 or UTF-8 collating sequence.
EBCDIC and Unicode UTF-16 SORT Order
The collating sequence of Unicode UTF-16 is different than that of EBCDIC. The SORT command allows you to reorder the data. The SORT command always operates on the underlying data; thus, when the data is Unicode, the results may be different than for EBCDIC data.
The following table shows the difference between Unicode UTF-16 order and EBCDIC order.
SORT Order for EBCDIC and Unicode UTF-16
EBCDIC | Unicode UTF-16 | ||
---|---|---|---|
Order | HEX Value | Order | HEX Value |
Space | X’40’ | Space | X’0020’ |
Lowercase letters | X’81’ to X’89’ | Numbers | X’0030’ to X’0039’ |
Uppercase letters | X’C1’ to X’C9’ | Uppercase letters | X’0041’ to X’005A’ |
Numbers | X’F0’ to X’F9’ | Lowercase letters | X’0061’ to X’007A’ |
EBCDIC and Unicode UTF-8 SORT Order
The collating sequence of Unicode UTF-8 is different than that of EBCDIC. The SORT command allows you to reorder the data. The SORT command always operates on the underlying data; thus, when the data is Unicode, the results may be different than for EBCDIC data.
The following table shows the difference between Unicode UTF-8 order and EBCDIC order.
SORT Order for EBCDIC and Unicode UTF-8
EBCDIC | Unicode UTF-8 | ||
---|---|---|---|
Order | HEX Value | Order | HEX Value |
Space | X’40’ | Space | X’20’ |
Numbers | X’F0’ to X’F9’ | Numbers | X’30’ to X’39’ |
Lowercase letters | X’81’ to X’89’ | Uppercase letters | X’41’ to X’5A’ |
Uppercase letters | X’C1’ to X’C9’ | Lowercase letters | X’61’ to X’7A’ |
Double byte Uppercase letters | X'C1C1' to X'C1DA' | ||
Double byte Lowercase letters | X'C1E1' to X'C1FA' |