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.
In reply to Re: Random array sorting
by Aristotle
in thread Random array sorting
by kidd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |