SORT
Sorts the members of an existing result set.
Syntax
SORT [setname>] BY expression [ASCENDING|DESCENDING]
Parameters
setname | The name of a result set. If setname is not specified, the current set is used. |
expression | An expression that identifies a field to be used as a sort key. Complex expressions must be enclosed in parentheses. |
ASCENDING or DESCENDING | Specifies how the sort on the associated key is to be performed. ASCENDING (default) Sorts in “alphabetical order” (A-Z, 0-9). DESCENDING Sorts in “reverse alphabetical order” (Z-A, 9-0). |
Example
find all Employees where Name = Smith -> SmithNames
sort SmithNames by Salary
The preceding two commands could be combined into one by using a SORTED BY subcommand.
sort SmithNames by FirstName DeptNum Salary descending
The preceding command sorts the employees named Smith by first name (ascending order), department (ascending order), and salary (descending order).