PDA

View Full Version : sorting images in array



sheSays
October 16th, 2002, 08:22 AM
hi,

i've placed some photographs in array...and now I want to sort them into sets such as "album1", "album2"....how do i do this? thanx. :)

pom
October 16th, 2002, 10:00 AM
Well, there are array sorting methods, but I don't know them. Maybe if Supra comes over, he'll tell us.

In the meantime, this seems to work:
album=new Array("album9","album4","album2","album1","album6","album5","album3","album7","album8");
result=new Array();

for (var i=0;i < album.length;i++){
index=album[i].slice(5);
result[index-1]=album[i];
}
trace (result);The "result" array contains all the album in the right order, provided that they start from album1.

pom :cowboy: