Application icon

Sort List

This function sorts a list contained in a field or named variable. You can sort based on the content of each list item or by treating each list item as a sub list and sorting on a specified set of sub-list items.

If the delimiter resolves to be empty when the action is executed, a default (\~) will be assumed.

All text fields may contained any of the escape sequences described in Escape Sequences.

You may choose to sort Ascending or Descending.

There are five ways the list can be sorted:

Compare
A standard case sensitive sort.

Case Insensitive
Alphabetic case is ignored.

As in Finder
Sorts the same way the Finder sorts items. Case insensitive and items with leading numeric values sort numerically. eg. 10 title will appear after 2 title.

Numeric
Sorts based on the integer value of each list item. Note that if a list item does not have a leading integer, it is treated as zero. While As in Finder handles some integer cases it does not handle items with leading zeros properly. ie. it does not normalize leading integer values. Items with the same value are sorted As in Finder. This provides a deterministic sort order.

Length
Sorts based on the length of each list item. Items with the same length are sorted As in Finder. This provides a deterministic sort order.

The following only applies if you are sorting based on the items in sub-lists.

The above options specifies the default value for each descriptor.

If the sub-list delimiter resolves to be empty when the action is executed, a ➤ (\,) sequence is assumed.

You specify a list of sort descriptors describing how the sort is performed. The field may contain up to 10 sort descriptors. Sort descriptors may be separated by commas or spaces. A sort descriptor has the following components. (Note that sort descriptors are case insensitive).

A or D
This component is optional. It allows you to override the default sort direction set in the above options. A implies Ascending and D implies Descending.

C or I or F or N or L
This component is optional and allows you to override the sort function set in the above options. C is for Compare, I is for Case Insensitive, F is for As in Finder, N is for Numeric and L is for Length.

an integer
This is the zero based index of the sub-list item which is the sort parameter.

Example:

You could enter the following to sort:

default direction: Ascending
default function: As in Finder
descriptors: I0 D3 9

If an invalid descriptor is found at runtime, it and all subsequent descriptors are ignored. If an invalid index is found at runtime, equality is assumed while comparing.