Please sign in to comment.
Replace hackish generators/shuffle with a fisher-yates implementation
This: (sort (fn [_] (long)) coll) Does not work on JDK7 since TimSort is clever enough to detect that the ordering function is behaving inconsistently, resulting in: java.lang.IllegalArgumentException: Comparison method violates its general contract! Also, this is just a bad idea: A variant of the above method that has seen some use in languages that support sorting with user-specified comparison functions is to shuffle a list by sorting it with a comparison function that returns random values. However, this is an extremely bad method: it is very likely to produce highly non-uniform distributions, which in addition depends heavily on the sorting algorithm used. http://en.wikipedia.org/wiki/Fisher–Yates_shuffle#Comparison_with_other_shuffling_algorithms We can't use clojure.core/shuffle since we want whatever shuffling we do to be repeatable given the same input and same initial state of the random number generator. This patch provides an implementation of the fisher-yates shuffle and then replaces the body of shuffle with a call to said function. Signed-off-by: Stuart Halloway <firstname.lastname@example.org>
- Loading branch information...
Showing with 16 additions and 1 deletion.