Alex Baranosky <alexander.barano...@gmail.com> writes:

> So for the case I had that method worked.  I wonder though if I had
> wanted to sort by multiple keys, with some of the keys sorting in
> reverse order and others in regular order, how I could do that...  Say
> last name ascending, date of 
> birth descending for example.

Write your own compare function which does that.  For example, for the
general case:

(def asc compare)
(def desc #(compare %2 %1))

(defn compare-by [[k comp & more] x y]
  (let [result (comp (k x) (k y))]
    (if (and (zero? result) (seq more))
      (recur more x y)
      result)))

(sort #(compare-by [:last-name asc, :date-of-birth desc] %1 %2) coll)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to