|
Array.sortOn
Availability
Flash Player 6.
Usage
Array.sortOn( fieldName )
Parameters
fieldName A string that identifies a field in an element of the Array to be used as the sort value.
Returns
None.
Description
Method; sorts the elements in an array based on a field in the array. If no fieldName parameter is passed, the function fails. If multiple fieldName parameters are passed, the first field is converted to a string value and the remaining parameters are ignored.
If either of the elements being compared does not contain the field specified in the fieldName parameter, the sort defaults to the behavior in the Array.sort method.
Example
This following example creates a new array and sorts it based on the field city :
var recArray = new Array();
recArray.push( { name: "bob", city: "omaha", zip: 68144 } );
recArray.push( { name: "greg", city: "kansas city", zip: 72345 } );
recArray.push( { name: "chris", city: "burlingame", zip: 94010 } );
recArray.sortOn("city");
// results in the following:
recArray[0] = name: "chris", city: "burlingame", zip: 94010
recArray[1] = name: "greg", city: "kansas city", zip: 72345
recArray[2] = name: "bob", city: "omaha", zip: 68144
See also
Array.sort
|