... BY field1 [ASCENDING|DESCENDING] [AS TEXT]
field2 [ASCENDING|DESCENDING] [AS TEXT]
... .
1. ... ASCENDING|DESCENDING
2. ... AS TEXT
If a sort key is specified with the addition BY, sorting is not done by field group header, but by the fields field1 field2 ... specified after that. For field1 field2 ..., components of the field group header or field groups that contain solely fields of the field group header are specified. The sort priority depends on the sequence in which the components field1 field2 ... are specified. The number of fields to be used for sorting is limited to 50.
For field1 field2 ..., field symbols can also be specified.
If a component of the field group header is assigned to
a field symbol during execution of the statement, sorting takes place according to the respective component.
If no data object is assigned to a field symbol, the specification is ignored. If a different data object is assigned to a field symbol, an exception that cannot be handles is triggered.
... ASCENDING|DESCENDING
If, after a component field1 field2 ..., none of the additions
ASCENDING or DESCENDING
is specified, a predefined sort direction is adopted. If one of the additions
ASCENDING or DESCENDING is specified, it overwrites the default for this component.
... AS TEXT
Without the addition AS TEXT after a text-type component
field1 field2 ..., the default is adopted. If, after a
text-type component, the addition AS TEXT is specified,
it overwrites the default for this component. In the case of non-text-type components,
AS TEXT cannot be specified. If AS TEXT is after a field group, the addition only has an effect on the text-type components of this group.