Fast-path SORT command
The SORT command can be used as a primary (fast-path) command by typing the appropriate SORT syntax in the Option line of any report panel and pressing Enter.
The functionality supports both single and multi-column sorting and enables users to specify sort order (ascending or descending) for each column in the sort.
Syntax for single-column sorting
The syntax for single-column sorting is as follows:
SORT column_identifier dir
Where column_identifier is either the column name or the relative column number and dir is the direction in which to sort the column data. Valid values for dir are:
- asc
- (Default) Sorts data in ascending order.
- desc
- Sorts data in descending order.
- There must be a space between the column_identifier and its dir (if used).
- The relative column number for a column is determined based on the column's placement when visible on the screen. Thus, relative column numbers are only available for columns currently visible on the screen. Relative column numbers are determined by counting the displayed columns from left to right, with the leftmost visible column being assigned the number '1' and each successive column (reading left to right) being assigned a relative column number that is incremented by 1. Hint: To quickly determine the column number, use the CNUM command to toggle on the column numbers for each display column.
- You can sort on a column that is not displayed if you use the column name (instead of the relative column number) as the column_identifier in the SORT syntax.
Multi-column sorting
The syntax for multi-column sorting is as follows:
SORT column_identifier dir column_identifier dir
Where column_identifier is either the column name or the relative column number and dir is an optional indication of the direction in which to sort the column data. Valid values for dir are:
- asc
- (Default) Sorts data in ascending order.
- desc
- Sorts data in descending order.
The column_identifier and dir values must all be separated by spaces. The maximum number of columns that can be sorted at once is 9.
Usage examples
For a report display that has three columns, all of which display on the screen:
Column 1: Name
Column 2 Creator
Column 3: Status
The following examples show how you can sort these columns:
- SORT NAME
- Sorts display data in ascending order based on the value in the Name column (when no dir value is specified, the default sort order is ascending, thus SORT NAME and SORT NAME A are synonymous).
- SORT NAME D
- Sorts display data in descending order based on the value in the Name column.
- SORT NAME DESC
- Sorts display data in descending order based on the value in the Name column.
- SORT NAME A CREATOR D
- Sorts display data first in ascending order based on the value in the Name column and then sorts data in descending order based on the value in the Creator column.
- SORT NAME ASC CREATOR DESC
- Sorts display data first in ascending order based on the value in the Name column and then sorts data in descending order based on the value in the Creator column.
- SORT 1 A
- Sorts display data in ascending order based on the value in the Name column.
- SORT 1 A CREATOR D
- Sorts display data first in ascending order based on the value in the Name column and then sorts data in descending order based on the value in the Creator column.
- SORT 3 2 1
- Sorts the display data first in ascending order based on the value in the Status column, then in ascending order based on the value in the Creator column, and finally in ascending order based on the value in the Name column.
SORT NAME D
SORT 'NAME' D
SORT "NAME" D