Skip to content

Instantly share code, notes, and snippets.

@whamtet
Last active May 5, 2026 17:13
Show Gist options
  • Select an option

  • Save whamtet/f8bfbb1d45580769a073bd1c45f49ebc to your computer and use it in GitHub Desktop.

Select an option

Save whamtet/f8bfbb1d45580769a073bd1c45f49ebc to your computer and use it in GitHub Desktop.
(defn- compare-possible-nums [a b]
(if (and a b (re-find #"^\d+$" a) (re-find #"^\d+$" b))
(- (Long/parseLong a) (Long/parseLong b))
(compare a b)))
(defn- compare-bits [[a & as] [b & bs]]
(let [c (compare-possible-nums a b)]
(if (and a (= 0 c))
(compare-bits as bs)
c)))
(defn- compare-names [a b]
(compare-bits
(->> a .toLowerCase (re-seq #"\d+|\D+"))
(->> b .toLowerCase (re-seq #"\d+|\D+"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment