03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

sortOn (Array.sortOn method)<br />

public sortOn(fieldName:Object, [options:Object]) : Array<br />

Sorts the elements in an array according to one or more fields in the array. The array should<br />

have the following characteristics:<br />

■ The array is an indexed array, not an associative array.<br />

■ Each element of the array holds an object with one or more properties.<br />

■ All of the objects have at least one property in common, the values of which can be used to<br />

sort the array. Such a property is called a field.<br />

If you pass multiple fieldName parameters, the first field represents the primary sort field, the<br />

second represents the next sort field, <strong>and</strong> so on. Flash sorts according to Unicode values.<br />

(ASCII is a subset of Unicode.) If either of the elements being compared does not contain the<br />

field specified in the fieldName parameter, the field is assumed to be undefined, <strong>and</strong> the<br />

elements are placed consecutively in the sorted array in no particular order.<br />

By default, Array.sortOn() works as described in the following list:<br />

■ Sorting is case-sensitive (Z precedes a).<br />

■ Sorting is ascending (a precedes b).<br />

■ The array is modified to reflect the sort order; multiple elements that have identical sort<br />

fields are placed consecutively in the sorted array in no particular order.<br />

■ Numeric fields are sorted as if they were strings, so 100 precedes 99, because "1" is a lower<br />

string value than "9".<br />

You can use the options parameter to override the default sort behavior. If you want to sort a<br />

simple array (for example, an array with only one field), or if you want to specify a sort order<br />

that the options parameter doesn't support, use Array.sort().<br />

To pass multiple flags, separate them with the bitwise OR (|) operator:<br />

my_array.sortOn(someFieldName, Array.DESCENDING | Array.NUMERIC);<br />

Parameters<br />

fieldName:Object - A string that identifies a field to be used as the sort value, or an array in<br />

which the first element represents the primary sort field, the second represents the secondary<br />

sort field, <strong>and</strong> so on.<br />

options:Object [optional] - One or more numbers or names of defined constants, separated<br />

by the | (bitwise OR) operator, that change the sorting behavior. The following values are<br />

acceptable for the options parameter:<br />

■ Array.CASEINSENSITIVE or 1<br />

■ Array.DESCENDING or 2<br />

Array 245

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!