Re: Random Array Sort?

From: Date: Fri, 18 Oct 2002 18:47:34 +0000
Subject: Re: Random Array Sort?
Groups: php.general 
Request: Send a blank email to php-general+get-120547@lists.php.net to get a copy of this message
How about the fibanachi sequence. The value in array elem x is the value in array elemet with index -> x-1 + x-2 % ( rand() ) >>> Steve Keller <skeller@healthtvchannel.org> 10/18/02 12:43PM >>> I looked in the guide and couldn't find an easy way to do this, like a multisort, so I thought I'd ask here and see if anyone can point me to the command or share code if they've done something like this. I have an array with numbers in the fields, say 1, 2, 3, 4 and 5 in the first 5 slots. Now I want to sort them, but randomly. The only way I could think to do this is to create a loop, run it a random number of times, and in the loop, swap two random elements. Can anyone think of an easier/more logical way? -- S. Keller UI Engineer The Health TV Channel, Inc. (a non - profit organization) 3820 Lake Otis Pkwy. Anchorage, AK 99508 907.770.6200 ext.220 907.336.6205 (fax) Email: skeller@healthtvchannel.org Web: www.healthtvchannel.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#120547) next »