ActionScript 2.0 Components Language Reference |
|
|
|
| DataProvider API > DataProvider.sortItems() | |||
Flash Player 7.
Flash MX Professional 2004.
myDP.sortItems([compareFunc], [optionsFlag])
compareFunc A reference to a function that compares two items to determine their sort order. For more information, see the Array.sort() method in ActionScript 2.0 Language Reference. This parameter is optional.
optionsFlag Lets you perform multiple, different types of sorts on a single array without having to replicate the entire array or resort it repeatedly. This parameter is optional.
The following are possible values for optionsFlag:
Array.DESCENDING, which sorts highest to lowest.Array.CASEINSENSITIVE, which sorts case-insensitively.Array.NUMERIC, which sorts numerically if the two elements being compared are numbers. If they aren't numbers, use a string comparison (which can be case-insensitive if that flag is specified).Array.UNIQUESORT, which returns an error code (0) instead of a sorted array if two objects in the array are identical or have identical sort fields.Array.RETURNINDEXEDARRAY, which returns an integer index array that is the result of the sort. For example, the following array would return the second line of code and the array would remain unchanged:
["a", "d", "c", "b"] [0, 3, 2, 1]
You can combine these options into one value. For example, the following code combines options 3 and 1:
array.sort (Array.NUMERIC | Array.DESCENDING)
Nothing.
Method; sorts the items in the data provider according to the specified compare function or according to one or more specified sort options.
This method triggers the modelChanged event with the event name sort.
This example sorts according to uppercase labels. The items a and b are passed to the function and contain label and data fields:
myList.sortItems(upperCaseFunc);
function upperCaseFunc(a,b){
return a.label.toUpperCase() > b.label.toUpperCase();
}
|
|
|
|