Skip to content

Instantly share code, notes, and snippets.

@kuanyui
Created May 16, 2017 13:10
Show Gist options
  • Save kuanyui/bd014e589eb9922129f96e5caca904de to your computer and use it in GitHub Desktop.
Save kuanyui/bd014e589eb9922129f96e5caca904de to your computer and use it in GitHub Desktop.
(defun sort-ip (ip-list)
(sort ip-list #'>ip))
(defun >ip (a b)
(if (and (null a) (null b))
nil
(let ((x (car a))
(y (car b)))
(cond ((> x y) t)
((< x y) nil)
(t (>ip (cdr a) (cdr b)))
))))
(sort-ip '((192 168 1 20) (1 1 1 1) (255 0 0 0) (192 168 1 1) (192 16 2 20) (192 168 1 1) (111 168 1 20)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment