
July 10th, 2004, 01:02 PM
|
|
Registered User
|
|
Join Date: Mar 2004
Posts: 7
Time spent in forums: 20 m 15 sec
Reputation Power: 0
|
|
Creating a 'predictable' random array sort
I am trying to figure out a way to create an array sorting algorithm that if handed an array of the same elements, will shuffle them in into exact the same 'random' order.
For instance, I have an array filled with the values: flour, eggs, milk, sugar, water
I need to pull the values in exactly that order in one part of the code, but I need them to be randomized for the next part. This script is called numerous times and each time the values that are randomized must always be in the same order as the previous time the script was called.
For instance, using the above example of "flour, eggs, milk, sugar, water", the randomized output might be "water, milk, eggs, flour, sugar". The next time the script is run, the randomization needs to be "water, milk, eggs, flour, sugar" if handed the exact same array of "flour, eggs, milk, sugar, water" just as before.
How could I go about doing this without making the array shuffle truly random?
I do not want to use natcasesort(), rsort(), or whatever as those are always too predictable.
|