Groups | Blog | Home
all groups > flash actionscript > march 2007 >

flash actionscript : simple sort routine for a text field


chopTheWood
3/23/2007 6:44:01 PM
Does anyone have an example script that will take the contents of a dynamic
text field and sort it?
Such as:
one
two
three
four
----will become:
four
one
three
two

lines are separated by line breaks
thanks


kglad
3/23/2007 7:12:09 PM
you can use the flash split() method of strings to form an array with each line
as an element and then use the flash sort() method of arrays to sort your array
elements and finally use the flash join() method of arrays to form a string
that can then be assigned to the text property of a textfield for display.
AddThis Social Bookmark Button