开发者

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]);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜