SORT
SORT field_spec [REVERSE] [LINEBREAK] [PAGEBREAK] [MERGE] [BY field_spec [REVERSE] [LINEBREAK] [PAGEBREAK] [MERGE]...]
Arguments
field_spec
A specification for a field in a report. See Field_spec definition.
REVERSE
(optional) Reverses the sort order of the current sort field.
LINEBREAK
(optional) Inserts a line break in the report whenever the value of the current sort field changes.
PAGEBREAK
(optional) Inserts a page break in the report whenever the value of the current sort field changes.
MERGE
(optional) Allows multiple projection files to be treated as one for the purpose of sorting.
BY
(optional) Indicates that another sort field will follow.
Discussion
The SORT statement describes a sort field. Sort fields help control the organization of a report. The order in which the sort fields are specified determines the sort levels within a report. The maximum number of sort fields is 10.
Examples
- The report in the example below has one sort level (CUST_TAG.STATE). All records from the first (alphabetically sorted) state are printed, then all records from the second state, and so on.
SORT CUST_TAG.STATE
- In the example below, the report has two sort levels: CUST_TAG.CITY and CUSTOMER.CUST_NAME. The second sort level also defines a line break, so after each change in CUSTOMER.CUST_NAME, a line break is printed. All records from the first (alphabetically sorted) city are printed, then all records from the second city are printed, and so forth. For each city, all records from the first (alphabetically sorted) customer name are printed, then all records from the second customer name, and so on.
SORT CUST_TAG.CITY BY CUSTOMER.CUST_NAME LINEBREAK