in reply to •Re: Random array sorting
in thread Random array sorting

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Random array sorting
by merlyn (Sage) on Dec 05, 2007 at 18:31 UTC
    That's been shown time and time again to not be a "fair" shuffle, and in earlier Perl versions, would actually lose data or even core-dump. Bad. And yeah, I tried it in order to find that out.
Re^3: Random array sorting
by ikegami (Patriarch) on Dec 05, 2007 at 18:41 UTC

    Ignoring that it doesn't work, I don't see how

    print $_, "\n" foreach (sort {int(rand(3))-1} @array);

    is easier than

    print $_, "\n" foreach shuffle @array;