Command SORT Foundation
Copies sorted records to a new file.
SORT TO <cFilename> ; ON <cFieldname> [ [/A | /D] [/C] ] ; [, <cFieldname> [ [/A | /D] [/C] ] ... ] ; [FOR <lForCondition>] ; [WHILE <lWhileCondition>] ; [NEXT <nCount>] ; [RECORD <xRecordID>] ; [REST] ; [ALL] [FIELDS FieldNameList | FIELDS LIKE Skeleton | FIELDS EXCEPT Skeleton] [NOOPTIMIZE]
The file command SORT copies the records from a work area to a target file in a sorted order. The target file must not be open prior to calling the procedure. If the file already exists, it is overwritten without warning.
The function only sorts by fields and not by expressions. This means at least one field name <cFieldname> must be specified. Memo fields cannot be sorted. Character fields are sorted according to their ASCII value, numeric fields according to numeric value and date fields are sorted chronologically. For logical fields, the lesser value is .F. (false).
The sort range can be limited by specifying conditions or the number of records to sort. If SET DELETED is set to ON, records marked for deletion are not copied. Filtered records are also ignored if a filter condition is active.
In network environment, the source file in the work area must be locked or exclusively open.
The functional equivalent of SORT is the function DbSort().
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.