(let [mymap (into {} (for [x (shuffle (rest (clojure.string/split "abcdefghijklmnopqrstuvwxyz" #"")))]
{x {:idx (rand-int 24)}}))]
(into (sorted-map-by (fn [k1 k2]
(compare [(get-in mymap [k1 :idx]) k1]
[(get-in mymap [k2 :idx]) k2])))
mymap))
or
(let [mymap (into {} (for [x (shuffle (rest (clojure.string/split "abcdefghijklmnopqrstuvwxyz" #"")))]
{x {:idx (rand-int 24)}}))]
(->> mymap
(sort-by (fn [[_ m]] (:idx m)))
(into (array-map))))
=> {"d" {:idx 22}, "n" {:idx 22}, "z" {:idx 14}, "w" {:idx 11}, "s" {:idx 17}, "f" {:idx 20}, "e" {:idx 19}, "q" {:idx 12}, "p" {:idx 10}, "j" {:idx 0}, "x" {:idx 20}, "v" {:idx 14}, "a" {:idx 1}, "t" {:idx 13}, "i" {:idx 21}, "k" {:idx 16}, "b" {:idx 23}, "r" {:idx 3}, "y" {:idx 18}, "g" {:idx 0}, "l" {:idx 16}, "u" {:idx 20}, "h" {:idx 10}, "m" {:idx 16}, "o" {:idx 11}, "c" {:idx 4}}
If we limit the amount to 8 is ok.
(let [mymap (into {} (for [x (shuffle (rest (clojure.string/split "abcdefghijklmnopqrstuvwxyz" #"")))]
{x (rand-int 24)}))]
(into (sorted-map-by (fn [k1 k2]
(compare [(get mymap k1) k1]
[(get mymap k2) k2])))
(take 8 mymap)))
{"z" {:idx 1}, "q" {:idx 6}, "n" {:idx 7}, "s" {:idx 7}, "f" {:idx 9}, "d" {:idx 17}, "w" {:idx 18}, "e" {:idx 21}}
may be associated with Clojurescript Array-Map order