DEV Community

Discussion on: Daily Challenge #253 - Sort Sentences Pseudo-alphabetically

Collapse
quoll profile image
Paula Gearon
(refer-clojure :exclude '[sort])
(require '[clojure.string :as s])
(defn sort
  [s]
  (->> (s/split s #"[^\w]+")
       (sort-by first
                (fn [a b]
                  (if (Character/isUpperCase a)
                    (compare b a)
                    (if (Character/isLowerCase b) (compare a b) -1))))
       (s/join " ")))