Array Sorting according to two or more values
How ca开发者_StackOverflow社区n i accomplish sorting an array according to two values. Is there built in function for that?
Use the sortOn() function.
Answer:
In my loop I insert values into my array like so:
for(var i:uint = 0; i < xmlList.length(); i++)
{
sortArray[i].year = xmlList[i].year;
sortArray[i].month = xmlList[i].month;
}
And to sort this array: (edited)
sortArray.sortOn(['year', 'month'], [Array.NUMERIC, Array.NUMERIC]);
精彩评论