[Python-ideas] Shuffled

Bernardo Sulzbach mafagafogigante at gmail.com
Tue Sep 6 14:46:49 EDT 2016


On 09/06/2016 03:37 PM, Sven R. Kunze wrote:
>
> Besides being a silly argument, it's an interesting solution.
>
> Does it really work? I remember Microsoft utilizing a similar approach
> for their browser selection tool which led to a skewed probability
> distribution. Maybe, I wrong here though.
>

Yes. The key is evaluated only once, so each element gets a 
pseudo-random number. Sorting this list leads to a shuffle.

However, a super-linear shuffle, whilst Fisher-Yates is a linear 
solution and also requires less additional memory.

Lastly, although it is obvious, from a software engineering standpoint, 
this is a mere weird hack.



More information about the Python-ideas mailing list