```
sort [sortDirection] [sortStyle] ¬
by expression
sort [this] stack [sortDirection] ¬
[sortStyle] by expression
sort [marked] cards [of this stack] ¬
[sortDirection] [sortStyle] ¬
by expression
sort bkgnd [sortDirection] ¬
[sortStyle] by expression
sort [marked] cards of bkgnd ¬
[sortDirection] [sortStyle ] ¬
by expression
sort [chunks of] container ¬
[sortDirection] [sortStyle] ¬
[by expression]
```
where chunks are limited to either lines or items.
The first five forms of the sort command order all the cards in a stack or background by the value of expression, evaluated for each card in the stack or background.
The last form of the sort command (by expression ) sorts lines or items of a container by any expression. If you don’t specify, sort orders by lines. Before expression is evaluated for each line or item of the container, the local variable each is set to the contents of the chunk. (Click the Examples button to see syntax examples using each.)
For all forms of the sort command, the default sort direction is ascending, and the default sort style is text.
Sort direction ascending orders the sort elements—the value of the expression on each card or the lines or items in the container—from lower to higher values.
Sort direction descending orders the sort elements from higher to lower values.
Sort style text compares the sort elements based on their ASCII values:
"1" < "101" < "2" < "a" < "ab" < "b"
Note that neither case nor diacritical marks matter with the sort style text:
`"apple" = "APPLE" = "äpplé"`
Sort style numeric correctly sorts numbers. With sort style text,
`"1" < "100" < "17" < "2"`
The sort style numeric correctly sorts these values as:
"1" < "2" < "17" < "100"
The sort style dateTime orders the sort elements by their date or time format. (See the convert command for valid date and time formats.)
The sort style international correctly sorts non-English text containing diacritical marks and special characters based on the international resource installed in the current stack, the Home stack, HyperCard itself, or the System file.