Re: Random Array Sort?

From: Date: Fri, 18 Oct 2002 19:30:57 +0000
Subject: Re: Random Array Sort?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-120552@lists.php.net to get a copy of this message
On Saturday 19 October 2002 02:43, Steve Keller wrote: > 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? shuffle() ? -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* Lack of money is the root of all evil. -- George Bernard Shaw */

« previous php.general (#120552) next »