- or download this
use List::Util "shuffle";
sub shuffleArray{
shuffle(@_);
}
- or download this
sub shuffleArray{
my @p = @_;
...
0 .. @p - 1;
@p;
}
- or download this
sub shuffleArray{
my @p = @_;
map { splice @p, $_ + rand(@p - $_), 1, $p[$_] } 0 .. @p - 1;
}
- or download this
sub shuffleArray{
my @p = @_;
my $t;
map { $t = splice @p, rand(@p), 1, $p[0]; shift @p; $t } 0 ..
+@p - 1;
}
- or download this
sub shuffleArray{
my @w = map { rand } @_;
@_[sort { $w[$a] <=> $w[$b] } 0 .. @_ - 1];
}
- or download this
sub shuffleArray{
map { $$_[1] } sort { $$a[0] <=> $$b[0] } map { [rand, $_] } @
+_;
}
- or download this
sub shuffleArray{
map { $$_[0] } sort { ref $a <=> ref $b } map { bless [$_], ra
+nd } @_;
}