Array.sort()
Availability
Flash Player 5; additional capabilities added in Flash Player 7.
Usage
my_array.sort() : Array
my_array.sort(compareFunction:Function) : Array
my_array.sort(option:Number | option |... ) : Array
my_array.sort(compareFunction:Function, option:Number | option |... ) : Array
Parameters
compareFunction
an array. Given the elements A and B, the result of
following three values:
•
-1, if A should appear before B in the sorted sequence
•
0, if A equals B
•
1, if A should appear after B in the sorted sequence
One or more numbers or names of defined constants, separated by the
option
operator, that change the behavior of the sort from the default. The following values are
acceptable for
option
•
1 or
Array.CASEINSENSITIVE
•
2 or
Array.DESCENDING
•
4 or
Array.UNIQUESORT
•
8 or
Array.RETURNINDEXEDARRAY
•
16 or
Array.NUMERIC
For information on this parameter, see Array.sortOn().
Note: Array.sort() is defined in ECMA-262, but the array sorting options introduced in Flash
Player 7 are Flash-specific extensions to the ECMA-262 specification.
Returns
The return value depends on whether you pass any parameters, as described in the following list:
•
If you specify a value of 4 or
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
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.
Description
Method; sorts the elements in an array. Flash sorts according to Unicode values. (ASCII is a subset
of Unicode.)
114
Chapter 2: ActionScript Language Reference
A comparison function used to determine the sorting order of elements in
:
Array.UNIQUESORT
Array.RETURNINDEXEDARRAY
can have one of the
compareFunction
for
and two or more elements being
option
for
option
| (bitwise OR)
, Flash returns an array
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?
Questions and answers