As you continue to work on various Flash applications you come across many challenges that aren't always a big deal, but sometimes you can't overcome them. Although it may be true that I face frequent challenges, I am able to find a solution because I think about it and try to find it on paper. I cannot explain the process that I go through in my head, but I can tell you that it gets confusing when lots of thoughts are going through your mind.
What is sortArray( )
The function sortArray ( ) is one of the many functions I created while working with ActionScript. It all started when I was trying to order a set of numbers from least to greatest, and there was no function in Flash that could do that so I had to figure it out myself. An example would be this.
var numbersArray = [2,5,10,4,8,14]
What the sortArray ( ) does is return an array with the numbers ordered from least to greatest like this.
sortArray ( numbersArray ) = [2,4,5,8,10,14]
In this tutorial I will try to explain how the function works or if you want, you can just grab the code and leave.
How to use sortArray( )
Well let me just show you an example of how it would be used. Lets say I have an array called 'numbersArray' with my own set of numbers.
var numbersArray = [4,5,1,8];
Then I have an empty variable that will hold the newly ordered array.
Now I use the function.
numbersArrayOrdered = sortArray ( numbersArray );
If I trace 'numbersArrayOrdered' you get this output.
Now lets see the code for the function.
|» Level Intermediate|
Rating: 4 Votes: 13
|16 years old. Likes Flash. male.|
|Download the files used in this tutorial.|
|Download (2 kb)|
|More help? Search our boards for quick answers!|