Last active
May 5, 2026 17:13
-
-
Save whamtet/f8bfbb1d45580769a073bd1c45f49ebc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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