Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Random array sorting

by Aristotle (Chancellor)
on Sep 22, 2002 at 15:15 UTC ( #199903=note: print w/replies, xml ) Need Help??


in reply to Random array sorting

See merlyn's reply below.

sub shuffle { my @shuffled; push @shuffed, splice(@_, rand(@_), 1) while @_; return @shuffled; } print shuffle @array;

The splice pulls a random element out of the array, which is pushed onto the new array. Repeat while there are still elements in the list.

Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://199903]
help
Chatterbox?
[beech]: checking chatterbox sidebar
[beech]: and again a check on chatterbox sidebar, what is expandability
beech me me me me me me testing chatterbox sidebar
beech my my /me me me me me me me chatterbox sidebar
beech testing chatterbox sidebar
[beech]: and something else

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2017-03-27 22:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (324 votes). Check out past polls.