User Guide

260 ActionScript classes
Availability: ActionScript 1.0; Flash Player 6 - The options parameter was added in Flash
Player 7. The ability to use different options parameters on multiple sort fields was added in
Flash Player 8.
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:
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, a value of 0 is returned and the array
is not modified.
If you specify a value of 8 or Array.RETURNINDEXEDARRAY for the options parameter, an
array is returned that reflects the results of the sort and the array is not modified.
Otherwise, nothing is returned and the array is modified 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.
var rec_array:Array = new Array();
rec_array.push({name: "john", city: "omaha", zip: 68144});
rec_array.push({name: "john", city: "kansas city", zip: 72345});
rec_array.push({name: "bob", city: "omaha", zip: 94010});
for(i=0; i<rec_array.length; i++){
trace(rec_array[i].name + ", " + rec_array[i].city);