Array.sort()
249
option
One or more numbers or names of defined constants, separated by the
|
(bitwise OR)
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
Array.UNIQUESORT
for
option
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
option
, 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.
Description
Method; sorts the elements in an array. Flash sorts according to Unicode values. (ASCII is a subset
of Unicode.)
By default,
Array
.
sort()
works as described in the following list:
•
Sorting is case-sensitive (
Z
precedes
a
).
•
Sorting is ascending (
a
precedes
b
).
•
The array is modified to reflect the sort order; multiple elements that have identical sort fields
are placed consecutively in the sorted array in no particular order.
•
Numeric fields are sorted as if they were strings, so 100 precedes 99, because “1” is a lower
string value than “9”.
If you want to sort in another way, create a function to do the sorting and pass its name as the
compareFunction
parameter. You might do this, for example, if you want to sort alphabetically
by last name, ascending, and then by ZIP code, descending.
If you want to specify one or more fields on which to sort, using either the default sort or the
options
parameter, use
Array.sortOn()
.
Summary of Contents for FLEX-FLEX ACTIONSCRIPT LANGUAGE
Page 1: ...Flex ActionScript Language Reference...
Page 8: ......
Page 66: ...66 Chapter 2 Creating Custom Classes with ActionScript 2 0...
Page 76: ......
Page 133: ...break 133 See also for for in do while while switch case continue throw try catch finally...
Page 135: ...case 135 See also break default strict equality switch...
Page 146: ...146 Chapter 5 ActionScript Core Language Elements See also break continue while...
Page 808: ...808 Chapter 7 ActionScript for Flash...
Page 810: ...810 Appendix A Deprecated Flash 4 operators...
Page 815: ...Other keys 815 Num Lock 144 186 187 _ 189 191 192 219 220 221 222 Key Key code...
Page 816: ...816 Appendix B Keyboard Keys and Key Code Values...
Page 822: ...822 Index...