ActionScript 2.0 Components Language Reference |
|
|
|
| List component > List.sortItems() | |||
Flash Player 6 (6.0.79.0).
Flash MX 2004.
listInstance.sortItems(compareFunc)
compareFunc A reference to a function. This function is used to compare two items to determine their sort order.
For more information, see the Array.sort() method in ActionScript 2.0 Language Reference.
Nothing.
Method; sorts the items in the list by using the function specified in the compareFunc parameter.
The following example sorts the items according to uppercase labels. Note that the a and b parameters that are passed to the function are items that have label and data properties.
var my_list:mx.controls.List;
my_list.setSize(200, 100);
my_list.addItem({data:"flash", label:"Flash"});
my_list.addItem({data:"dreamweaver", label:"Dreamweaver"});
my_list.addItem({data:"coldfusion", label:"ColdFusion"});
my_list.sortItems(upperCaseFunc);
function upperCaseFunc(a:Object, b:Object):Boolean {
return (a.label.toUpperCase() > b.label.toUpperCase());
}
|
|
|
|