Well the order of your strings is something subjective...
You should use Array.sort([function]) and create a custom sorting
function that would sort your array the way you want:
var array:Array = ["seventy-four", "ten", "twelve"];
function sortByStringLength(a:Object, b:Object):Number {
if (String(a).length > String(b).length) return 1;
else if (String(a).length < String(b).length) return -1;
return 0;
}
array.sort(sortByStringLength);
for(var i in array) { trace(array[i]); }
outputs:
seventy-four
twelve
ten
Mendelsohn, Michael a écrit :
Hi list...
From the help on "for...in":
You can also iterate through the elements of an array:
var myArray:Array = ["one", "two", "three"];
for (var i:String in myArray) {
trace(myArray[i]);
}
This code outputs the following in the Output panel:
three
two
One
Why is the data output in reverse order and is there any way of ordering
it one,two,three?
Thanks,
- Michael M.
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com