Function DbSort() Foundation
Sorts records from a work area and writes them into a file.
DbSort( <cFilename>, ; <aFieldnames>, ; [<bForCondition>], ; [<bWhileCondition>], ; [<nCount>], ; [<xRecordID>], ; [<lRest>] ) --> lSuccess
The function DbSort() returns a logical value indicating whether the operation executed successfully. If the value equals .T. (true), the sort was completed.
The function DbSort() writes the records from a work area into a target file in a sorted order. The target file must not be open during the operation. If the target file already exists, it is overwritten without warning.
This function sorts only by fields and not by expressions. At least one field name must be contained as a character string in the array <aFieldnames>. Memo fields cannot be sorted. Character fields are sorted according to their ASCII value, numeric fields by numeric value and date fields chronologically. Logical fields are sorted with .F. (false) is the lesser value.
Sort order is ascending (A->Z) by default. If the characters "/D" are placed after a field name ("FieldName /D"), the field is sorted in descending order (Z->A). For character fields, the characters "/C" may also be included with the field name to indicate that no differentiation between upper and lower case letters should be made during sorting.
The sorted records can be limited by conditions or by specifying the number of records. If SET DELETED is turned ON, records with a deletion flag are not copied. Also, records filtered out are not copied if a filter condition is active.
In a multi-user environment, the source file in the work area must be locked or be exclusively opened.
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.