SORT stage v1.0 |
Pipelines v2.0 |
Purpose, Operands, Streams used, Usage notes, Examples, See also |
Syntax |
_Ascending__
>>__SORT___ ________ __| Padtype |__ _________ __|____________|________________________><
|_COUNT__| |_ANYCase_| |_Descending_|
|_UNIQue_| |_| Group |__|
Padtype:
_NOPAD____
|__|__________|_________________________________________________________________________|
|_PAD_char_|
Group:
<_________________________________________
_Ascending__ |
|____columnrange__|____________|__| Padtype |_|_________________________________________|
|_Descending_|
Notes:
(1) columnrange is unsigned.
Purpose |
Use the SORT stage to arrange records
in ascending or descending order. SORT reads records from its primary input
stream and writes the records to its primary output stream. SORT reads all
records from its primary input stream before it writes any records to its
primary output stream.
By default, SORT compares the
entire record to determine the order of records in its output stream. However,
you can specify one or more key fields to determine the sequence of records in
the output stream. A key field is a specific range of columns within each
record.
Operands |
● |
COUNT specifies that each record in the output stream is prefaced with a 10-character field that represents the number of records with identical key fields. The number is right-justified with leading spaces. Records are considered to be identical if the specified key fields contain the same data. If a key field is not specified, records are considered to be identical if they contain exactly the same data. When COUNT is specified, only the
first record is retained; duplicate records are discarded. |
||||
● |
UNIQue writes all unique records and the first record of each set of duplicate records to the output stream. Records are considered to be identical if the specified key fields contain the same data. If a key field is not specified, records are considered to be identical if they contain the same data. |
||||
● |
NOPAD specifies that shorter key fields are not extended with a pad character before they are compared with longer key fields in other records. The NOPAD operand can be specified in two positions on the SORT stage: |
||||
|
|
||||
● |
PAD specifies that shorter key fields are extended with a pad character before they are compared with longer key fields in other records. The PAD operand can be specified in two positions on the SORT stage: |
||||
|
|
||||
|
|
||||
● |
ANYCase specifies
that key fields are compared in uppercase. In effect this means that a
non-case-sensitive comparison is made when sorting the records. |
||||
● |
Ascending sorts records in ascending order. The ASCENDING operand can be specified in two positions on the SORT stage: |
||||
|
|
||||
● |
Descending sorts records in descending order. The DESCENDING operand can be specified in two positions on the SORT stage: |
||||
|
|
||||
● |
is an
unsigned integer column range which defines a key field to sort on. If you do
not specify columnrange, the
complete record is compared. If you
specify more than one column range, you must place at least one space between
each one that you specify. |
Streams used |
The following streams are used by the SORT stage:
Stream |
Action |
|
|
Primary input stream |
SORT reads all records from its
primary input stream before writing any output records.
|
Primary output stream |
After sorting the records read
from the input stream, SORT writes the records to its primary output stream. |
Usage notes |
1) |
SORT delays the records until end-of-file is
reached on its primary input stream. |
2) |
If you do not specify COUNT or UNIQUE, records that are
identical or have specified key fields that are identical remain in the same
order as in the input stream. |
3) |
If the key fields in two records are of differing lengths
when SORT is determining their order in the output stream, a position that is
not present in one record is less than the contents of a record that has any
character in that position. Use the PAD operand to extend a key field with a
specific character. |
4) |
When you specify more than one column range, the records
are sorted within each range. For example: **** Top of file **** 01 Address Rxpipe 02 03 ‘pipe literal /a b c@b b a@b a a/’, 04 ‘| split at string /@/’, 05 ‘| sort 5 1 3’, 06 ‘| console’ 07 08 Exit 0 **** End of file ****
Output: b a a b b a a b c |
5) |
SORT verifies that its secondary
input and output streams are not connected and then begins execution. |
Examples |
A file list sorted by date and
time
See also |
Reference the following links for
additional information:
History of change |
None.
|