Quote:
Originally Posted by macdonjo
I want cdSorted to be sorted and cdCollection to be left untouched.
|
To do that you need to work with another array so that the first one is not touched by whatever you do with the second one. There's an easy way to duplicate an array which creates a copy of an existing one:
ActionScript Code:
var cdCollection:Array = ["Tuskegee","Love Is A Four Letter Word","21","California 37","Up All Night"];
var cdSorted:Array;
cdSorted = cdCollection.concat();//concat without arguments creates a copy
cdSorted.sort();
trace(cdCollection);
trace(cdSorted);