Previous Topic: SFNext Topic: STATS


SORT

Sorts the records according to your specifications. If you do not specify operands, the records in the data set are sorted into ascending order. If the data set is VSAM, the default sort key is the key column for a KSDS, the RBA for an ESDS, and the RRN for an RRDS. Otherwise, the default sort key is the entire record.

Syntax:

   SORT [fcol1 lcol1[A|D]]…[fcol10 lcol10[A|D]
      [KEY[A|D]]
      [X|NX|ALL]
      [label1 label2]

Syntax Description:

SORT

Sorts and displays the data according to the sort criteria.

fcol1

Beginning column for the sort area.

lcol1

Ending column for the sort area.

A

Sorts the records in ascending order.

D

Sorts the records in descending order.

Note: If you specify a column range but do not specify a sort order, the previously specified sort order is used.

Default: A

KEY

An alias for the column range that contains the VSAM key.

Specify up to ten sort keys. Specify each starting (fcolx) and ending (lcolx) column. You can also specify the sort order direction. When specified, a direction defaults to the most recently specified column range, and to all ranges that follow.

X

Only sorts excluded lines.

NX

Only sorts non-excluded lines.

label1

Specifies the beginning point in a range of lines to apply the sort.

label2

Specifies the ending point in a range of lines to apply the sort.

Examples:

SORT   KEY D

Sort on VSAM key into descending sequence

SORT   10 20 30 40

Sort on columns 10-20 and 30-40, in ascending sequence

SORT   10 20 D 30 40 50 60 A

Sort on columns 10-20 and 30-40 in descending sequence and columns 50-60 in ascending sequence