
Array.splice() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
452
|
ActionScript Language Reference
The sort order is indeterminate when multiple elements have the identical value for the key
property. In this case, sortOn() may produce inconsistent results between multiple calls.
For example:
function Contact (firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
Contact.prototype.toString = function () {
return this.firstName + " " + this.lastName;
}
// Populate a contacts array with Contact instances that
// share identical lastName property values.
var contacts = new Array();
contacts[0] = new Contact("Makiko", "Pitaru");
contacts[1] = new Contact("Amit", "Pitaru");
contacts[2] = new Contact("Richard", "Clayton");
contacts[3] = new Contact("Derek", "Clayton");
// Sort by lastName...
contacts.sortOn("lastName");
trace(contacts); // Displays:
// Richard Clayton,Derek Clayton,Makiko Pitaru,Amit Pitaru
// Sort AGAIN by lastName...
contacts.sortOn("lastName");
trace(contacts); // Displays DIFFERENT RESULTS:
// Richard Clayton,Derek Clayton,Amit Pitaru,Makiko Pitaru
See Also
Array.sort()
Array.splice() Method
remove elements from, and/or add elements to, an array
Flash 5
array.splice(startIndex)
array.splice(startIndex, deleteCount)
array.splice(startIndex, deleteCount, value1,...valuen)
Arguments
startIndex The zero-relative ...