Macromedia flash support the ability to sortOn elements in a
multidimensional array. Support for key sorting either through XML
nodes or JavaScript multidimensional arrays would be great.
ie:
var items = new Array();
items.push({title: "Star Wars", year: "1977"});
items.push({title: "Empire Strikes Back", year: "1980"});
items.push({title: "Return of the Jedi", year: "1983"});
items.sortOn("title");
items.sortOn("year");
Unless something like that already exists and I just haven't found
it yet.
Javascript lets you pass a comparison function to the Array.sort
function, so you can do specific types of sorting by writing a
function that will determine which item should go where in the list.
This function will sort based on the title:
function sortTitle(a, b) {
if (a.title > b.title) return 1;
else if (a.title < b.title) return -1;
else return 0;
}
items.sort(sortTitle);
To emulate ActionScript's Array.sortOn method, you can add it into
the Array prototype, like so:
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/dashboard-dev/email@hidden