random shuffles

Boris Borcic bborcic at gmail.com
Fri Jul 21 07:11:42 EDT 2006


does

x.sort(cmp = lambda x,y : cmp(random.random(),0.5))

pick a random shuffle of x with uniform distribution ?

Intuitively, assuming list.sort() does a minimal number of comparisons to 
achieve the sort, I'd say the answer is yes. But I don't feel quite confortable 
with the intuition... can anyone think of a more solid argumentation ?

- BB
--
"On naît tous les mètres du même monde"



More information about the Python-list mailing list