数组和集合 / 数组

(def numbers [11 2 5 7 3])

;; sort returns a sorted seq, the source vector stays as it was
(println (sort numbers))                  ; (2 3 5 7 11)
(println (vec (sort numbers)))            ; [2 3 5 7 11]
(println numbers)                         ; [11 2 5 7 3]

;; descending — pass the comparator
(println (vec (sort > numbers)))          ; [11 7 5 3 2]

(def pairs [["B" 3] ["A" 2] ["C" 1]])
(prn (sort-by first pairs))               ; by the first element
(prn (sort-by second > pairs))            ; by the second, descending