Shuffle: sorting effect

Does line c sortlead to a more random array or is sortit just waste?

use List::Util qw(shuffle);


@random1 = shuffle sort keys %vocables;

@random2 = shuffle keys %vocables;
+5
source share
2 answers

If you put the sort before the shuffle changes, then the shuffle will be broken. Since shuffle works, sorting is a waste of processor time. The whole point of a good shuffle is to eliminate any pre-existing ordering of elements.

+10
source

“Variety” does not make it more random and represents waste

+10
source

All Articles