Search Tutorials
Sorting STRING ArraysSorting STRING Arrays is fairly easy, because you can use the predefinedsort() function. Here's an example :
function sortstring()
{
test = new Array();
test[0] = "House";
test[1] = "Ball";
test[2] = "Dog";
test.sort();
for (i=0; i<3; i++) {
trace (test[i] + " ");
}
}
This function first initialises a new Array called test. Then it assignsthree String values to the first three instances of the Array. Afterwards, the Array test is sorted using the sort() function, which sorts the Array in alphabetical order. The output will look like this : Ball Dog House
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|