Copies the current table to a new table, arranging records in the specified order.


ON <field 1> [/A | /D [/C]]
  [,<field 2> [/A | /D [/C]]...]
[FOR <condition 1>]
[WHILE <condition 2>]


The new table file to copy and sort the current table's records to.


Specifies the type of table you want to create, if <filename> does not include an extension. This option overrides the current SET DBTYPE setting. The TYPE keyword is included for readability only; it has no effect on the operation of the command.

ON <field 1>

Makes <field 1> the first field of <filename>and sorts <filename> records by the values in <field 1>, which can be any data type except binary, memo, or OLE.


Sorts records in ascending order (A to Z; 1 to 9; past to future (blank dates come after non-blank dates); false then true). Since this is the default sort order, include /A for readability only.


Sorts records in descending order.


Removes the distinction between uppercase and lowercase letters. When you specify both A and C, or both D and C, use only one forward slash (for example, /DC).

<field 2> [/A | /D [/C]] ...

Sorts on a second field so that the new table is ordered first according to <field 1>, then, for identical values of <field 1>, according to <field 2>. If a third field is specified, records with identical values in <field 1> and in <field 2> are then sorted according to <field 3>. The sorting continues in this way for as many fields as are specified.

FOR <condition 1>
WHILE <condition 2>

The scope of the command. The default scope is ALL.


Sorts all specified fields for which you don't include a sort order in ascending order. Since this is the default, include ASCENDING for readability only.


Sorts all specified fields for which you don't include a sort order in descending order.


The SORT command creates a new table in which the records in the current table are positioned in the order of the specified key fields.

SORT creates a temporary index file. During the sorting process, your disk must have space for this temporary index file and the new table file.

SORT differs from INDEX in that it creates a new table rather than provide an index to the original table. Although using SORT is generally not as efficient as using an index to organize tables, you might want to use SORT for the following applications:

To archive an outdated table and store it in a sorted order

To create a table that is a sorted subset of an original table

To maintain a small table that needs to be sorted in only one order

To create an ordered table where record numbers are sequential and contiguous


No equivalent.