How would one sort an indexed array and maintain the index association in Actionscript 3.0. The Array.sort(); method seems to reindex the array no matter what. Basically I need to recreate the arsort php function in Actionscript. Possible?
How would one sort an indexed array and maintain the index association in Actionscript
Share
To do so you would need an associative array (i.e. an
Object) because when the indexes are integers flash would automatically reorder them from 0 to n as you may have noticed (This can be quite annoying in your case, but has its reasons).If you want to keep track of the key values, a hack is to store the indexes in the value for each item in the array :
This will trace :
n.b. This can be improved if your values are strong typed in a
Vectorinstead of anArray.