in reply to unsorted list
You can use rand within the sort code.
@stuff = qw[ cat dog pig cow ]; print "$_\n" for sort { rand() <=> rand() } @stuff
Update. I have the (theoretical) feeling that this trick may cause an infinite loop when used with a large array, but a few tests I did returned nothing suspicious.
HTH
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: unsorted list
by merlyn (Sage) on Apr 24, 2005 at 13:32 UTC | |
Re^2: unsorted list
by Roy Johnson (Monsignor) on Apr 24, 2005 at 12:55 UTC |
In Section
Seekers of Perl Wisdom