Sorting the data

You can sort your data by using the SORT primary command. With this command, you can sort the data in any of the following ways:

Note: SORT requires that all data set records be memory-resident. If the entire data set can not fit into your region storage, an error is reported and the SORT execution aborted. If necessary, increase the region size to contain the entire data set.

You can specify whether you want the data sorted in ascending (the default) or descending sequence and, in Edit, you can restrict the sorting to excluded records or not-excluded records only.

To sort by a column range:

  1. Display your data in CHAR, HEX or LHEX format.
  2. Enter the SORT primary command, followed by up to five pairs of column range values. For example:
    SORT 56 70 3 22
    sorts a data set into ascending order, using the range 56-70 as the first key and range 3-22 as the second key.

To sort by field references:

  1. Display your data in TABL format (requires that you have specified a template).
  2. Enter the SORT primary command, followed by up to five field references. For example:
    SORT #6 D #3 D
    sorts a data set into descending order, using field #6 as the first key and field #3 as the second key.

To restore a list to the KEY or SLOT NUMBER order (KSDS, VRDS, and RRDS VSAM data sets):

  1. Display your KSDS, VRDS, or RRDS VSAM data set in any display format.
  2. Sort the data away from the KEY or SLOT NUMBER order by issuing a SORT command, by moving or adding records or by editing the key field (KSDS only). If you have edited your records, issue the SAVE command.
  3. Restore your data to its KEY or SLOT NUMBER order by issuing the SORT command followed by the KEY parameter, for example:
    SORT KEY.
    sorts a data set into descending order, using field #6 as the first key and field #3 as the second key.

Examples

Related topics