User Guide

262 ActionScript classes
}
}
trace("Unsorted:");
//Displays Unsorted:
trace(passwords_array);
//Displays mom:glam,ana:ring,jay:mag,anne:home,regina:silly.
//Writes mom:glam,ana:ring,jay:mag,anne:home,regina:silly
passwords_array.sort(order);
trace("Sorted:");
//Displays Sorted:
trace(passwords_array);
//Displays ana:ring,anne:home,jay:mag,mom:glam,regina:silly.
//Writes ana:ring,anne:home,jay:mag,mom:glam,regina:silly.
See also
| bitwise OR operator, sortOn (Array.sortOn method)
sortOn (Array.sortOn method)
public sortOn(fieldName:Object, [options:Object]) : Array
Sorts the elements in an array according to one or more fields in the array. The array should
have the following characteristics:
The array is an indexed array, not an associative array.
Each element of the array holds an object with one or more properties.
All of the objects have at least one property in common, the values of which can be used to
sort the array. Such a property is called a field.
If you pass multiple
fieldName parameters, the first field represents the primary sort field, the
second represents the next sort field, and so on. Flash sorts according to Unicode values.
(ASCII is a subset of Unicode.) If either of the elements being compared does not contain the
field specified in the
fieldName parameter, the field is assumed to be undefined, and the
elements are placed consecutively in the sorted array in no particular order.
By default,
Array.sortOn() 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".