Array.sort()
281
Description
Method; extracts a slice or a substring of the array and returns it as a new array without modifying
the original array. The returned array includes the
start
element and all elements up to, but not
including, the
end
element.
If you don’t pass any parameters, a duplicate of
my_array
is created.
Array.sort()
Availability
Flash Player 5; additional capabilities added in Flash Player 7.
Usage
my_array
.sort()
my_array
.sort(
compareFunction
)
my_array
.sort(
option
|
option
|... )
my_array
.sort(
compareFunction
,
option
|
option
|... )
Parameters
compareFunction
An optional comparison function used to determine the sorting order of
elements in an array. Given the elements A and B, the result of
compareFunction
can have one of
the following three values:
•
-1 if A should appear before B in the sorted sequence
•
0 if A = B
•
1 if A should appear after B in the sorted sequence
option
One or more numbers or strings, 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.UNIQUE
•
8 or
Array.RETURNINDEXEDARRAY
•
16 or
Array.NUMERIC
For information on this parameter, see
Array.sortOn()
.
Returns
The return value depends on whether you pass any parameters:
•
If you specify a value of 4 or Array.UNIQUE 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.
Summary of Contents for FLASH MX 2004 - ACTIONSCRIPT
Page 1: ...ActionScript Reference Guide...
Page 8: ...8 Contents...
Page 12: ......
Page 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Page 54: ...54 Chapter 2 ActionScript Basics...
Page 80: ...80 Chapter 3 Writing and Debugging Scripts...
Page 82: ......
Page 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Page 112: ......
Page 120: ...120 Chapter 6 Using the Built In Classes...
Page 176: ......
Page 192: ...192 Chapter 10 Working with External Data...
Page 202: ...202 Chapter 11 Working with External Media...
Page 204: ......
Page 782: ...782 Chapter 12 ActionScript Dictionary...
Page 793: ...Other keys 793 221 222 Key Key code...
Page 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Page 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Page 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Page 816: ...816 Index...