Skip to content

Instantly share code, notes, and snippets.

@mamboking
Created August 23, 2011 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mamboking/1165309 to your computer and use it in GitHub Desktop.
Save mamboking/1165309 to your computer and use it in GitHub Desktop.
sort by length & frequency
;;Hett's Problem 1.28
(def test-list [[:a :b :c] [:d :e] [:f :g :h] [:d :e] [:i :j :k :l] [:m :n] [:o]])
(defn sort-by-length [some-list]
(sort-by count some-list))
(defn sort-by-length-freq [some-list]
(let [freq-map (frequencies (map count test-list))]
(sort-by (fn [l] (freq-map (count l))) some-list)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment