[racket-dev] How about adding this simple list-shuffling procedure to racket?

From: Neil Toronto (neil.toronto at gmail.com)
Date: Thu Nov 11 12:18:45 EST 2010

Eric Hanchrow wrote:
> I find myself using this all the time; it seems it'd be handy to have built in.
> (define (shuffled list)
>   (sort list < #:key (lambda (_) (random)) #:cache-keys? #t))

Is the distribution of shuffled lists uniform? That'd be hard to 
analyze, since it would depend on the sorting algorithm. I would guess 
it's not.

(Don't worry if you didn't catch this yourself. It's not exactly 

If you want an "unbiased" shuffle, see


Neil T

Posted on the dev mailing list.