in reply to Re: Re: Re^2: When the Best Solution Isn't
in thread When the Best Solution Isn't
It requires you send it an actual array, of course, but it is just as fast.sub shuffle (\@) { my $d = shift; my @r = map rand, 0 .. $#$d; @$d[sort { $r[$a] <=> $r[$b] } 0 .. $#$d] = @$d; }
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re^2: When the Best Solution Isn't
by diotalevi (Canon) on Sep 23, 2002 at 14:40 UTC |