Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: sort to shuffle

by demerphq (Chancellor)
on Sep 03, 2001 at 15:06 UTC ( [id://109842]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub fy_shuf{my($l,$c,$r)=@_;map{$r=int(rand($_+1));
    @$l[$_,$r]=@$l[$r,$_]}reverse 0..$#$l for 0..$c||0};
    
    my @a=(1..52);
    fy_shuf(\@a,5);
    
  2. or download this
    sub fy_shuf{my($l,$r)=@_;map{$r=int(rand(@$l-$_+1));@$l[-$_,$r]=@$l[$r
    +,-$_]}0..$#$l};
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://109842]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-12-09 10:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (53 votes). Check out past polls.