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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

string value than "9".<br />

If you want to sort an array by using settings that deviate from the default settings, you can<br />

either use one of the sorting options described in the entry for the options parameter or you<br />

can create your own custom function to do the sorting. If you create a custom function, you<br />

can use it by calling the sort() method, using the name of your custom function as the first<br />

parameter (compareFunction).<br />

Parameters<br />

compareFunction:Object [optional] - A comparison function used to determine the sorting<br />

order of elements in an array. Given the elements A <strong>and</strong> B, the result of compareFunction<br />

can have one of the following three values:<br />

■ -1, if A should appear before B in the sorted sequence<br />

■ 0, if A equals B<br />

■ 1, if A should appear after B in the sorted sequence<br />

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

by the | (bitwise OR) operator, that change the behavior of the sort from the default. The<br />

following values are acceptable for the options parameter:<br />

■ Array.CASEINSENSITIVE or 1<br />

■ Array.DESCENDING or 2<br />

■ Array.UNIQUESORT or 4<br />

■ Array.RETURNINDEXEDARRAY or 8<br />

■ Array.NUMERIC or 16<br />

For more information about this parameter, see the Array.sortOn() method.<br />

Note: Array.sort() is defined in ECMA-262, but the array sorting options introduced in<br />

Flash Player 7 are Flash-specific extensions to the ECMA-262 specification.<br />

Returns<br />

Array - The return value depends on whether you pass any parameters, as described in the<br />

following list:<br />

■ If you specify a value of 4 or Array.UNIQUESORT for the options parameter <strong>and</strong> two or<br />

more elements being sorted have identical sort fields, Flash returns a value of 0 <strong>and</strong> does<br />

not modify the array.<br />

■ If you specify a value of 8 or Array.RETURNINDEXEDARRAY for the options parameter,<br />

Flash returns an array that reflects the results of the sort <strong>and</strong> does not modify the array.<br />

■ Otherwise, Flash returns nothing <strong>and</strong> modifies the array to reflect the sort order.<br />

Array 243

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

Saved successfully!

Ooh no, something went wrong!