Previous Topic: CONTROL-SECTION Control StatementNext Topic: NOSORT Control Statement


SORT Control Statement

The SORT control statement defines the sort sequence by which the input data is sorted for the report. Only one SORT control statement is allowed. This control statement is optional. However, it must be submitted if the NEWPAGE control statement in the REPORT-SECTION is used. If the SORT control statement is not submitted, the input file is sorted into ascending sequence by volume serial number. The format for the SORT control statement is:

SORT [sequence-]keyword... [sequence-]keyword

Control Statement Definition

SORT

Identifies the control statement. It must be followed by a space.

sequence

Defines the sequence order by which the data is sorted. Valid sequences are:

A

Ascending order (default)

D

Descending order

The sequence must be separated from the following keyword by a dash (-). If sequence is not specified, the default sequence is A (ascending order).

keyword

Defines the field to be sorted.

Multiple SORT fields (sequence-keyword) may be specified by separating the expressions by a space. The first keyword specified is the major sort field. There is a limit of six sort fields.