Sorts the members of an existing result set.
SORT [setname>] BY expression [ASCENDING|DESCENDING]
|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.
Sorts in “alphabetical order” (A-Z, 0-9).
Sorts in “reverse alphabetical order” (Z-A, 9-0).
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).