-
best way would probably be to use a quicksort function in Inline C on the raw data in the Int16Array
How would you iterate over array in inline C? Actually I'd love to pass typed array/arraybuffer or string to inline C and iterate over it to avoid flat strings. I know there is some stuff exported for compiled javascript but didn't know how to use it properly. I there any example? Tried to decipher some output of compiled javascript but it was too hard.
Yay JavaScript!
MDN says (for Array.sort): The default sort order is ascending, built upon converting the elements into strings, then comparing
So amazingly
[2,-1,0,-2,1].sort()
is meant to be broken!I'd stupidly thought that
Int16Array.sort
would behave the same asArray.sort
but it seems not...I have just fixed this, so if you try a 'cutting edge' build then it should work fine. It should even be a little faster!
Otherwise if you want to go even faster the best way would probably be to use a quicksort function in Inline C on the raw data in the Int16Array, but that is probably overkill :)