Please note that ExpatTech is close for the Christmas and New Year holidays. We will re-open on 2nd January 2024.

ExpatTech Techblog

Peter Todd 2010.09.27. 14:22

Flash Cookbook - Appendix - Sort array indices

Yes. This is about array sorting. So there is the problem, that we want to sort an array, but want to know more about the indices. For this reason there is an option for Array.sort() function, which specifies the return value of sort():

Array.RETURNINDEXEDARRAY.

See the code below:

var array:Array = ["a", "c", "b"];
var sort:Array = array.sort(Array.RETURNINDEXEDARRAY);
trace(array, sort);

//a,c,b 0,2,1

It didn't sort the array, but returned an array with the sorted indices.