[Python-ideas] Shuffled

אלעזר elazarg at gmail.com
Tue Sep 6 14:57:23 EDT 2016


(Just to be clear, I wasn't trying to suggest this as more than an ad-hoc
solution for a throwaway script. But to me, "sorted by random key" is
almost as obvious as "shuffled", perhaps more so for non english speakers
with little background in CS terms; the words "sorted" and "random" jumps
to the eye, and sometimes you don't need more than that)
~Elazar

בתאריך יום ג׳, 6 בספט' 2016, 21:48, מאת Bernardo Sulzbach ‏<
mafagafogigante at gmail.com>:

> 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.
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160906/2d8055e3/attachment.html>


More information about the Python-ideas mailing list