In AS3, Array.sort()
took some nice sorting options like:
But sadly Vector<T>.sort()
does not support these features, and simply takes a compareFunction:Function
argument so you can write your own sorting logic.
Is there any other way to quickly get a sorted indexed-array of a vector?
Check out the documentation : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Vector.html#sort()
It is still possible to use those options but you have to pass them in as the first parameter instead of the compare function.
myVector.sort(Array.DESCENDING|Array.RETURNINDEXEDARRAY);
RETURNINDEXEDARRAY
does not work in Flash Player 10+. It just returns the same original Vector<Number>
.
Unlike an Array, RETURNINDEXEDARRAY
option is ignored for the Vector.sort()
method. The returned Vector object is always the reference of the original object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With