We’re working on a project where we had to sort the vector in different ways, depending on the user selection.
So we find the sortOn function in AS3, which is perfect. But there’s a problem!
If you want to sort an array of objects, by one of it’s fild which is numeric, the sortOn sorts them as if the numbers are strings.
The solution is to add an additional parameter, like this:
programArray.sortOn(
"popularity-score"
, Array.NUMERIC);
programArray.sortOn(
"popularity-score"
, Array.DESCENDING | Array.NUMERIC);
No comments:
Post a Comment