So I have the following code to sort an XML list and then sort it on the “StartDate” property. The code below works fine. I’m actually wondering why its working because when I lookup the reference for Array.sortOn() this shouldn’t be working. I have no key defined in my array yet its still sorting okay…can anyone explain why its working or what its actually doing??
[AS]function sortEventXML() {
var eventList = events_xml.firstChild.childNodes;
for (var i=0; i <= eventList.length; i++) {
// Populate the Event Array
// 0 - Event
// 1 - StartDate
// 2 - EndDate
// 3 - Speaker
// 4 - Audience
// 5 - Sponsor
// 6 - Description
eventInfo_array* = [eventList*.attributes.Event,
eventList*.attributes.StartDate,
eventList*.attributes.EndDate,
eventList*.attributes.Speaker,
eventList*.attributes.Audience,
eventList*.attributes.Sponsor,
eventList*.attributes.Description];
}
trace("Before Sort: ")
for (i=0; i < eventInfo_array.length-1; i++) {
trace(eventInfo_array*[1])
}
// Sort array by the StartDate
eventInfo_array.sortOn(1); // How does this line work??
trace("After Sort: ")
for (i=0; i < eventInfo_array.length; i++) {
trace(eventInfo_array*[1])
}
}
[/AS]