I have an array with up to 10000 elements. These elements are sorted of
some kind and I need to reorganize the elements so that their positions
becomes absolutely random.

I guess my best approach would be to assign my own "sort" function to
the Array.sort() method which did nothing but return -1,0 or 1 randomly,
but I guess it would be necessary to "sort" the array many times in
order to make it truly random and that would take a lot of CPU power
with that many elements.

That sounds like a very bad idea :) As you say, you'd not be getting a very well randomised list even if you did the sort lots of times.

The basic randomisation algorithm is:

take a new array
for each element in the old array: add it at a random position in the new array

It's not really rocket science, but it should do the job perfectly well for your purposes.

Danny
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to