You can use the
options
simple array (for example, an array with only one field), or if you want to specify a sort order
that the
parameter doesn't support, use
options
To pass multiple flags, separate them with the bitwise OR (
my_array.sortOn(someFieldName, Array.DESCENDING | Array.NUMERIC);
Availability: ActionScript 1.0; Flash Lite 2.0
Parameters
- A string that identifies a field to be used as the sort value, or an array in
fieldName:Object
which the first element represents the primary sort field, the second represents the secondary
sort field, and so on.
[optional] - One or more numbers or names of defined constants, separated
options:Object
by the
(bitwise OR) operator, that change the sorting behavior. The following values are
|
acceptable for the
options
Array.CASEINSENSITIVE
■
■
Array.DESCENDING
■
Array.UNIQUESORT
Array.RETURNINDEXEDARRAY
■
or 16
■
Array.NUMERIC
Code hinting is enabled if you use the string form of the flag (for example,
rather than the numeric form (2).
Returns
- The return value depends on whether you pass any parameters, as described in the
Array
following list:
If you specify a value of 4 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
■
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
The first sort uses
name
as the first sort value and
city
parameter to override the default sort behavior. If you want to sort a
parameter:
or 1
or 2
or 4
or 8
Array.UNIQUESORT
Array.RETURNINDEXEDARRAY
as the first sort value and
as the second.
name
.
Array.sort()
) operator:
|
for the
parameter, and two or
options
for the
as the second. The second sort uses
city
)
DESCENDING
parameter,
options
and
fields.
name
city
Array
263
Need help?
Do you have a question about the FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE and is the answer not in the manual?