(defn rational-bozo-sort "Choose, compare & if necessary exchange random indices n times, using the implicit ordering given by the lookup function" [lookup s n] (let [a (to-array s) c (alength a)] (dotimes [_ n] (let [idx1 (rand-int c) idx2 (rand-int idx1) v1 (aget a idx1) v2 (aget a idx2)] (when (< (lookup v1) (lookup v2)) (aset a idx1 v2) (aset a idx2 v1)))) (vec a)))