# Array.sortOn() question...how is this working?

**URL:** <https://forum.kirupa.com/t/array-sorton-question-how-is-this-working/167005>\
**Category:** flash\
**Created:** [October 24, 2005, 6:04pm UTC](https://forum.kirupa.com/t/array-sorton-question-how-is-this-working/167005 "2005-10-24T18:04:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![serkios](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/serkios/32/608_2.png) [@serkios](https://forum.kirupa.com/u/serkios)\
**Post date:** [October 24, 2005, 6:04pm UTC](https://forum.kirupa.com/t/array-sorton-question-how-is-this-working/167005/1 "2005-10-24T18:04:30Z")

</div>

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 &lt;= 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 &lt; 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 &lt; eventInfo_array.length; i++) {
    trace(eventInfo_array*[1])
}

```

}  
[/AS]
