sort items in array by name
Hello fellows,
I need to sort String items in an Array.
Actually I need to organize children of a MOvieClip inside an Array.
I have a "menu" mc object which has 8 children with names "m1", "m2", and so on..... the last one is "m8" . They are NOT created dynamically.
the children are even organized in layers alphabetically.
i've already tried:
Code:
// for each (var item:MovieClip in menu)
// {
// menu_items.push(item);
//
// }
// menu_items.sort();
// this sort in a different order , but still unordered.
for (var i:int; i < menu.numChildren; i++)
{
var item:String = "m" + String(i);
trace (item); // ok it should work....
// menu_items[i] = menu.getChildByName(item);
// didn“t worked.
trace (menu.getChildByName("m1").name);
// ok, that traces "m1"
}
trace(menu_items[0].name);
trace(menu_items[1].name);
trace(menu_items[2].name);
trace(menu_items[3].name);
// always in the wrong order......
HELP!!!!:scared::crazy::confused: