Get the sorted order of an array's elements without changing the original array : Sort : Array Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Array » Sort »

 

Get the sorted order of an array's elements without changing the original array


 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var words:Array = ["t""r""a""j"];
        var indices:Array = words.sort(Array.RETURNINDEXEDARRAY);
        trace(words);   
        trace(indices)
        for(var i:int 0; i < words.length; i++) {
          trace(words[indices[i]]);
        }
    }
  }
}
t,r,a,j
2,3,1,0
a
j
r
t

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Array
» Sort