List.sortItems()

Availability

Flash Player 6 (6.0.79.0).

Edition

Flash MX 2004.

Usage

listInstance.sortItems(compareFunc)

Parameters

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.

Returns

Nothing.

Description

Method; sorts the items in the list by using the function specified in the compareFunc parameter.

Example

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());
}

See also

List.sortItemsBy()