Sort
This is an oldie-but-baddie command. Back in the days before indexes, it was an awfully important command, but it's been superseded so many times, we've lost count.SORT makes a copy of a table, physically ordering the records in the new table according to specified criteria. SORT is a resource hog—it can require as much as three times the disk space occupied by the table to do the copying. Because you can do the same thing with COPY TO and an index, or SELECT-SQL, there's not much reason to use SORT.In Visual FoxPro, SORT does have one pair of cool new clauses (FIELDS LIKE, FIELDS EXCEPT), but COPY TO has them, too. (Actually, FIELDS LIKE and FIELDS EXCEPT were added in FoxPro 2.6, but Microsoft didn't bother to tell very many people about them, then.)
Usage |
SORT TO cTable ON uFieldName1 [ / A | D ] [ /C ] [, uFieldName2 [ /A | D ] [ /C ] [ , ... ] ] [ ASCENDING | DESCENDING ] [ Scope ] [ FOR lForExpression ] [ WHILE lWhileExpression ] [ FIELDS cFieldList | LIKE cInclude | EXCEPT cExclude ] [ NOOPTIMIZE ] |
Example |
USE Employee && small enough to make this not too painful SORT ON Last_Name /C, First_Name /C TO EmpName * Here's a better way to do that SELECT * FROM Employee ; ORDER BY Last_Name, First_Name ; INTO TABLE EmpName |
See Also |