[racket] on reversing a list by way of sort

From: Asumu Takikawa (asumu at ccs.neu.edu)
Date: Mon Sep 15 23:50:49 EDT 2014

On 2014-09-15 18:57:51 -0700, Matthew Butterick wrote:
> Mike Bostock's visual demonstration of why naive sorting functions are false
> friends. As he and Henglein point out, transitivity of the comparator is
> essential.
>
> http://bost.ocks.org/mike/shuffle/compare.html

Thanks, that's really interesting. Also means that our implementation of
`shuffle` in Racket stdlib is not great:

  (define (shuffle l)
    (sort l < #:key (λ(_) (random)) #:cache-keys? #t))

(more prose on the algorithm here: http://bost.ocks.org/mike/algorithms/#shuffling)

Cheers,
Asumu

Posted on the users mailing list.