sort of array
- Started
- Last post
- 14 Responses
- JamesEngage
Hello,
I have an array of 8 numbers... e.g
How can I simple sort them, or moreover return an array that says what order they are in...
e.g
[34,65,87,69,12,6,23,9] would be
[5,6,8,7,3,2,4,1]as in 9 is the first in the list... help!
- REDWOOD0
Depends of the language you're programming at
- JamesEngage0
d'oh sorry... actionscript/flash
- JamesEngage0
ah... it is RETURNINDEXEDARRAY ... now working out how to use the bugger.
- REDWOOD0
does that mean you've already found it?
- JamesEngage0
i'm in the right ball aprk... but it seesm to be a big ball park ... any ideas?
- unfittoprint0
http://livedocs.macromedia.com/f…
check below.
- JamesEngage0
sorry unfit... can you give me an example... i'm going nut's it's giving me all sorts of different results...
if i have an array called origArray=[8,67,65,56,4,3,2,1]
how do i return it as another array say, newArray = [1,2,4,5,6,3,8]
i.e the new array says what order those original elemetns should be to make them in the correct order... James
- unfittoprint0
You might wanna use an array where the values of each index number relate to the array wou would like to sort. together with a for loop.
anyway [in german]:
http://www.flashforum.de/archiv/…
- MR_T0
Anyone who posts by teh name 'gutKnut' must be taken seriously.
- JamesEngage0
hmmm... i'm doing this but getting no output for x
c = [11, 15, 13, 14, 12];
x = c.sort(Array.NUMERIC | Array.RETURNINDEXEDARRAY);trace("original array is: "+ c);
trace("the output is: "+ x);
- MR_T0
Thats a flash7 bit of code...you may be outputting as flash 6.
You may want to look at waxpraxis.org. Branden Hal has a 'natural compare' there.
toodle pip
- JamesEngage0
ah ta... t, you're right... need to be in 6 so will take a look
- MR_T0
I have been having a cack at this too..but to no luck. If I have time I will check ut branden hall stuff. It's usually pretty good
- JamesEngage0
I think I'm going to just have a go at writing my own quick one... bascially have a sorted and unsorted and see where each one sits... due to the nature of the points I'm using they are never going to be the same so should be fine (not that I think that matters... ouch my brain is fried)