User Guide

328 DataProvider API
Description
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.
Example
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();
}
DataProvider.sortItemsBy()
Availability
Flash Player 7.
Edition
Flash MX Professional 2004.
Usage
myDP.sortItemsBy(fieldName, optionsFlag)
myDP.sortItemsBy(fieldName, order)
Parameters
fieldName A string that specifies the name of the field to use for sorting. This value is
usually
"label" or "data".
order A string that specifies whether to sort the items in ascending order ("ASC") or
descending order (
"DESC").
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—sorts highest to lowest.
Array.CASEINSENSITIVE—sorts case-insensitively.
Array.NUMERIC—sorts numerically if the two elements being compared are numbers. If
they arent numbers, use a string comparison (which can be case-insensitive if that flag is
specified).