Search tutorials
Sorting STRING Arrays
Sorting 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
| » Level Intermediate |
|
Added: 2001-06-13 Rating: 8 Votes: 28 |
| » Author |
| No details available. |
| » Download |
| Download the files used in this tutorial. |
| Download (20 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!