OpenFL: Array has no field sortOn

271 views Asked by At

I'm using OpenFL and I'm attempting to use this code I found...

pos.sortOn("cotangent", Array.NUMERIC | Array.DESCENDING);

...but I'm getting the error:

src/Main.hx:180: characters 2-12 : Array<{ yPoint : Float, xPoint : Float, cotangent : Float }> has no field sortOn
src/Main.hx:180: characters 26-39 : Class<Array> has no field NUMERIC
src/Main.hx:180: characters 42-58 : Class<Array> has no field DESCENDING

Now according to this 'sortOn' is an available method for AS3 arrays so what is the problem?

2

There are 2 answers

0
Andrew On

In Haxe you could use ArraySort. Something like here

0
heyitsbmo On

Haxe has a builtin standard Array class, which is what you're referencing, not AS3's Array. The Haxe Array is documented here: http://api.haxe.org/Array.html

If you don't care about a stable sort, you can use the sort method: http://api.haxe.org/Array.html#sort