Error getting tags :
error 404Error getting tags :
error 404 sort container | revDocs | RunRev
Welcome Guest (Log in)
Product Edition
sort container
Expander triangle

sort [{lines | items} of] container [direction] [sortType] [by sortKey]

Desktop, Web and Server
Platform Support
MacOS,Mac OS X,Windows,Linux
None required
Sorts the lines or items of a container into a new order.

sort field "Output"
sort items of myInfo by word 2 of each -- sort by word 2 of the line
sort lines of field thisField descending numeric by item x of each

Additional Comments
Expander triangle

Use the sort container command to shuffle the order of lines or items in a container.


The container is a field, button, or variable, or the message box.

The direction is either ascending or descending. If you don't specify a direction, the sort is ascending.

The sortType is one of text, numeric, or dateTime. If you don't specify a sortType, the sort is by text.

The sortKey is an expression that evaluates to a value for each line or item in the container. If the sortKey contains a chunk expression, the keyword each indicates that the chunk expression is evaluated for each line or item. If you don't specify a sortKey, the entire line (or item) is used as the sortKey.


If you don't specify lines or items, the lines of the container are sorted.

The sort international form is like sort text, except that it sorts accented characters together with their unaccented counterparts. For example, "" sorts between "e" and "f", rather than at the end of the alphabet as it would using the sort text form.

The each keyword, when used in the sortKey, specifies the entire line or item. You can use the each keyword in an expression, as a placeholder for the current line or item. For example, this statement sorts the lines of a variable by the third word of each line:

sort lines of myVariable by word 3 of each

You can use the each keyword in any expression, not just chunk expressions.

The sort text form sorts by the ASCII value of each character. The sort numeric form sorts by number. Use this form if the sortKey consists of numbers. The sort dateTime form treats the sortKey as a date and/or time.

The sort container command is a stable sort. This means that if the sortKey for two items or lines is the same, sorting does not change their order, so you can do two successive sorts to create subcategories within the major sort categories.

Tip: To create a custom sort order, use the eachkeyword to pass each line or item to a custom function. The valuereturned by the function is used as the sort key for that line or item. Note that it is not currently possible to debug custom sort functions, and doing so could make the IDE unstable. It is recommended to use logging messages instead.

User Comments
Expander triangle
User thumbnail
Oliver Kenyon
Apr 24, 2009
The ability to use custom sort functions makes sorting in Revolution quite powerful. For example if you want to sort a list of prices without preprocessing the list something like this could be done:

sort lines of field "Prices" descending numeric by stripCurrency(each)

private function stripCurrency pSearchItem
if char 1 of pSearchItem is "$" then
return char 2 to -1 of pSearchItem
return pSearchItem
end if
end stripCurrency

User thumbnail
Craig Newman (dunbarx)
Oct 21, 2010
Multiple stable sorts may be implemented directly by concatenating sortKeys:
sort container by sortKey1 & sortKey2 & sortKey3...
Sortkey order determines the sorting sequence