20090703

Sorting an ArrayCollection



public function sortCollection(arrayCollection : ArrayCollection) : void
{
//Create the sort field
var dataSortField:SortField = new SortField();

//name of the field of the object on which you wish to sort the Collection
dataSortField.name = "name";
dataSortField.caseInsensitive = true;

/*
If you wish to perform numeric sort then set:
dataSortField.numeric = true;
*/

//create the sort object
var dataSort:Sort = new Sort();
dataSort.fields = [dataSortField];

arrayCollection.sort = dataSort;
//refresh the collection to sort
arrayCollection.refresh();

}