RecordSet.sortItemsBy(fieldName, direction)
Returns true if the sort succeeds, or false if any errors occurred.
Method. Sorts all records in the RecordSet object without making a new copy. The sort key value for each record is the contents of the field identified by the field ID. The original order is not saved.
Sorting large RecordSet objects can take a long time. RecordSet objects that contain fewer than 2000 records should take less than one second on a computer with a Pentium 3 processor. Sort times increase rapidly as the number of records grows.
When two or more records have the same sort key value, they are not sorted in a special way. The original order of the records might not be preserved.
If the fieldName parameter identifies a field that does not exist in one or more records, then null is used as the key value for those records. Null sorts lower than any other value.
The sortItemsBy method may only be used on fully populated RecordSet objects.
All registered views will receive the following callback:
View.modelChanged("sort", 1, lastRecordNumber);
The following example demonstrates the sortItemsBy method:
#include "NetServices.as"
var productList =new RecordSet(["ProductName","Price","Color"]);
var itemToAdd = {ProductName:"magicbubbles",Price:1,Color:"0x987654"};
var itemToAdd2 = {ProductName:"kiddyshampoo",Price:7,Color:"0x876543"};
var itemToAdd3 = {ProductName:"dishes",Price:2,Color:"0x098763"};
productList.addItem(itemToAdd);
productList.addItem(itemToAdd2);
productList.addItem(itemToAdd3);
productList.sortItemsBy("ProductName");
productList.sortItemsBy("Price","DESC");
RecordSet.addView, RecordSet.filter, RecordSet.sort
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flashremoting/mx/Using_Flash_Remoting_MX/asDict44.htm