User Guide

Array 263
You can use the options parameter to override the default sort behavior. If you want to sort a
simple array (for example, an array with only one field), or if you want to specify a sort order
that the
options parameter doesn't support, use Array.sort().
To pass multiple flags, separate them with the bitwise OR (
|) operator:
my_array.sortOn(someFieldName, Array.DESCENDING | Array.NUMERIC);
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
fieldName:Object - A string that identifies a field to be used as the sort value, or an array in
which the first element represents the primary sort field, the second represents the secondary
sort field, and so on.
options:Object [optional] - One or more numbers or names of defined constants, separated
by the
| (bitwise OR) operator, that change the sorting behavior. The following values are
acceptable for the
options parameter:
Array.CASEINSENSITIVE or 1
Array.DESCENDING or 2
Array.UNIQUESORT or 4
Array.RETURNINDEXEDARRAY or 8
Array.NUMERIC or 16
Code hinting is enabled if you use the string form of the flag (for example,
DESCENDING)
rather than the numeric form (2).
Returns
Array - The return value depends on whether you pass any parameters, as described in the
following list:
If you specify a value of 4 or Array.UNIQUESORT for the options parameter, and two or
more elements being sorted have identical sort fields, Flash returns a value of 0 and does
not modify the array.
If you specify a value of 8 or Array.RETURNINDEXEDARRAY for the options parameter,
Flash returns an array that reflects the results of the sort and does not modify the array.
Otherwise, Flash returns nothing and modifies the array to reflect the sort order.
Example
The following example creates a new array and sorts it according to the
name and city fields.
The first sort uses
name as the first sort value and city as the second. The second sort uses
city as the first sort value and name as the second.