First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Andross


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.

var numbersArrayOrdered;

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

Added: 2004-08-24
Rating: 4 Votes: 13
» Author
16 years old. Likes Flash. male.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.