AS3 Vector.sort () doesn't use collation?

In AS3, Array.sort() took some good sorting options, such as:

  • Array.DESCENDING - Sorts an array of large and small
  • Array.RETURNINDEXEDARRAY - Returns an array of indices so you can keep track of which item has been sorted, where

But unfortunately, Vector<T>.sort() does not support these functions and simply accepts the compareFunction:Function argument so that you can write your own sorting logic.

Is there any other way to quickly get a sorted indexed array of a vector?

+6
source share
2 answers

RETURNINDEXEDARRAY does not work in Flash Player 10+. It just returns the same original Vector<Number> .

Unlike an array, the RETURNINDEXEDARRAY parameter is ignored for the Vector.sort() method. The returned vector object is always a reference to the original object.

+4
source

Check out the documentation: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Vector.html#sort ()

You can still use these parameters, but you should pass them as the first parameter instead of the comparison function.

  myVector.sort(Array.DESCENDING|Array.RETURNINDEXEDARRAY); 
+8
source

Source: https://habr.com/ru/post/918585/


All Articles