Getting Sorted Indices
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var aEmployees:Array = ["A", "P", "C", "H"];
var aSortedIndices:Array = aEmployees.sort(Array.RETURNINDEXEDARRAY);
trace(aEmployees.toString());
trace(aSortedIndices.toString());
for(var i:Number = 0; i < aSortedIndices.length; i++) {
trace(aEmployees[aSortedIndices[i]]);
}
}
}
}
/*
A,P,C,H
0,2,3,1
A
C
H
P
*/
Related examples in the same category