1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
*positions*
;=>
((9 . 98) (77 . 0) (17 . 30) (17 . 73) (83 . 3) (81 . 30) (99 . 99)
 (90 . 68) (21 . 81) (92 . 29))

;; 辞書順で比較
(sort (copy-list *positions*)
      (lambda (x y) 
        (cond ((< (car x) (car y)) 'T)
              ((= (car x) (car y)) (< (cdr x) (cdr y)))
              ('T nil))))
;=>
((9 . 98) (17 . 30) (17 . 73) (21 . 81) (77 . 0) (81 . 30) (83 . 3)
 (90 . 68) (92 . 29) (99 . 99))


;; (0, 0)からの距離で比較
(sort (copy-list *positions*) 
      #'< :key (lambda (x) (expt (+ (car x) (cdr x)) 1/2)))
;=>
((17 . 30) (77 . 0) (83 . 3) (17 . 73) (21 . 81) (9 . 98) (81 . 30)
 (92 . 29) (90 . 68) (99 . 99))