HELPLIB.HLB  —  SORT  /KEY
    Describes key fields, including the position, size, sorting
    order, and data type. Both the position and size of the key field
    must be specified, except for floating point data types where the
    size is known. By default, Sort reorders a file by sorting entire
    records with character data in ascending order. Any other type of
    key field must be specified. When you specify multiple keys, use
    a separate /KEY qualifier for each key.

    Format

      /KEY=(field [,...])

1  –  Fields

 POSITION:n

    Specifies the position of the first byte in the key field. A
    value of 1 to 32,767 may be specified. The first byte in a record
    is considered position 1. The POSITION:n field must be specified.
    (Note that the SIZE:n field must also be specified, except for
    floating point data types where the size is known.)

 SIZE:n

    Specifies the length of the key field. The total composite size
    of all keys and the original input record length must be less
    than 32,767 bytes. If the decimal sign is stored in a separate
    byte in the key field, that byte is not counted toward the size
    of the data.

    Both the POSITION:n and SIZE:n fields must be specified, except
    for floating point data types where the size is known.

    The data type of the key determines what values are acceptable
    when specifying size as well as the units in which the size is
    specified:

    o  1 to 32,767 (characters) for character data

    o  1, 2, 4, 8, or 16 (bytes) for binary data

       High-performance Sort/Merge: The high-performance Sort/Merge
       utility currently supports only 1, 2, 4, and 8-byte binary
       keys.

    o  1 to 31 (digits) for decimal data

    o  No value is necessary for floating point data

 ASCENDING

    Orders the sorting operation in ascending alphabetical or
    numerical order. ASCENDING is the default order.

 DESCENDING

    Orders the sorting operation in descending alphabetical or
    numerical order.

 CHARACTER

    Specifies character data in the key field. CHARACTER is the
    default data type.

 BINARY

    Specifies binary data in the key field.

 SIGNED

    Specifies signed binary or decimal data in key field. SIGNED is
    the default for binary and decimal data.

 UNSIGNED

    Specifies unsigned binary or decimal data in the key field.

 F_FLOATING

    Specifies F_FLOATING format data in the key field.

 D_FLOATING

    Specifies D_FLOATING format data in the key field.

 G_FLOATING

    Specifies G_FLOATING format data in the key field.

 H_FLOATING

    Specifies H_FLOATING format data in the key field.
    High-performance Sort/Merge: Not supported by the high-
    performance Sort/Merge utility.

 S_FLOATING

    On Alpha and I64 systems, specifies IEEE S_FLOATING format data
    in the key field.

 T_FLOATING

    On Alpha and I64 systems, specifies IEEE T_FLOATING format data
    in the key field.

 DECIMAL

    Specifies decimal data in the key field.

 TRAILING_SIGN

    Specifies trailing sign decimal data in the key field. TRAILING_
    SIGN is the default for decimal data.

 LEADING_SIGN

    Specifies leading sign decimal data in the key field. The leading
    sign must be in the first position of the field and the field
    must be left zero padded.

 OVERPUNCHED_SIGN

    Specifies overpunched decimal data in the key field. OVERPUNCHED_
    SIGN is the default for decimal data.

 SEPARATE_SIGN

    Specifies separate sign decimal data in the key field.

 ZONED

    Specifies zoned decimal data in the key field.
    High-performance Sort/Merge: Not supported by the high-
    performance Sort/Merge utility.

 PACKED_DECIMAL

    Specifies packed decimal data in the key field.

 NUMBER:n

    Specifies the order of priority of each key if you do not list
    multiple keys in the order of their priority. A value of 1 to 255
    may be specified.

2  –  Full Description

    The /KEY qualifier specifies all the necessary information about
    a key field. If the file is to be sorted using entire records
    with character data in ascending order, you do not need to
    specify the key information.

    When a key field must be described, you must specify both the
    position and the size of the key. In addition, if the sorting
    or merging operation is to be done in descending alphabetic or
    numeric order, specify DESCENDING in the key description.

    If the data in the key fields is not character data, you must
    specify the data type. The following data types are recognized by
    the Sort/Merge utility:

       BINARY, [SIGNED]
       BINARY, UNSIGNED
       CHARACTER
       DECIMAL, LEADING_SIGN, SEPARATE_SIGN [SIGNED]
       DECIMAL, LEADING_SIGN, [OVERPUNCHED_SIGN, SIGNED]
       DECIMAL [,SIGNED, TRAILING_SIGN, OVERPUNCHED_SIGN]
       DECIMAL, [TRAILING SIGN], SEPARATE_SIGN, [SIGNED]
       DECIMAL, UNSIGNED
       D_FLOATING
       F_FLOATING
       G_FLOATING
       H_FLOATING
       PACKED_DECIMAL
       S_FLOATING (Alpha and I64 systems only)
       T_FLOATING (Alpha and I64 systems only)
       ZONED

    The items in brackets are defaults and need not be specified.

    Multiple Keys

    You can specify up to 255 key fields in a sorting operation. If
    you do specify multiple keys, decide which is primary, which is
    secondary, and so on; then, in the command string, list them in
    the order of their priority.

    By default, Sort assigns 1 to the first key specified in the
    command line, 2 to the second key, and so on. If you do not list
    the keys in the order of their priority, specify the order of
    each with the parameter NUMBER:n.

    For each Sort key, you must use a separate /KEY qualifier.
    If Sort finds /KEY parameters repeated after a single /KEY
    qualifier, it does not treat these as specifications for multiple
    keys; instead, the duplicate parameters override previously
    specified parameters.

3  –  Example

  $ SORT/KEY=(POS:16,SIZ:3)/KEY=(POS:1,SIZ:11) -
  _$ /KEY=(POS:40,SIZ:2,DESC) YRENDAVG.DAT YRAVGSRT.LIS

      This SORT command identifies three key fields. The input file,
      YRENDAVG, is first sorted by the key beginning in position
      16, then by the key beginning in position 1, and finally by
      the key beginning in position 40. The third key used sorts in
      descending order.
Close Help