12. Report-Writer Statements : Report Setup Statements : .Sort Statement—Specify Sort Order of Reported Data
 
Share this page                  
.Sort Statement—Specify Sort Order of Reported Data
The .sort statement specifies the ordering of rows to be reported.
The .sort statement has the following format:
.sort | .srt {columnname[:sortorder] {, columnname[:sortorder]}}
The parameters for the .sort statement are as follows:
columnname
The name of a column in the table to be reported, or the label for a column in the result column list of the specified query. You can express columnname as a delimited identifier by enclosing it in double quotes ("), if you have previously specified the .delimid statement.
The columnname can be expressed as a variable. The colon (:) and the comma (,) must be explicitly stated and cannot be part of the sortorder variable.
sortorder
Either ascending (also a or asc or ascend) or descending (also d or desc or descend), depending on how you want the rows to be ordered. If neither is specified, the default is ascending.
The sortorder can be expressed as a variable. The colon (:) and the comma (,) must be explicitly stated and cannot be part of the sortorder variable.
$columnvariable
The variable whose value is the name of a column. Precede the variable with a dollar sign ($).
$sortorder
The variable whose value is a sort order that evaluates to an acceptable sort direction. For more information, see the description of sortorder in this table. Precede the variable with a dollar sign ($).