@array = sort { 0.5 <=> rand } @array;
I wouldn't recommend this. From sort:
The comparison function is required to behave. If it returns inconsistent results (sometimes saying $x[1] is less than $x[2] and sometimes saying the opposite, for example) the results are not well-defined.
One could argue about whether "well-defined" simply means that the sort order isn't well-defined, or whether it means that something might blow up, but "The comparison function is required to behave." is a pretty clear statement.
Update: I see ikegami beat me to it.
In reply to Re: RFC: Kinda pseudo-shuffle using sort
by haukex
in thread RFC: Kinda pseudo-shuffle using sort
by rsFalse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |