Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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.

Comment on Re: Random array sorting
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2016-02-12 07:03 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (389 votes), past polls