It's straightforward to sort a bunch of maps by a single key:

  (sort-by :foo x) 

But how best to sort by primary, secondary(, ...) sort keys?  An elegant 
idiom can be found on briancarper.net*, where it was refined for Clojure 
1.1 by Malcolm Sparks:

  (sort-by (juxt :foo :bar) x)

In a very legible and thorough 2013 survey, Andy Fingerhut presents more 
details of the technique, including a trap for the unwary that makes his 
page well worth reading.**

Question:  Is it supported by documentation?  Or is any expectation of 
vectors' Comparable behavior a bit reckless?


* http://briancarper.net/blog/488/sort-a-clojure-map-by-two-or-more-keys

** 
https://github.com/jafingerhut/thalia/blob/master/doc/other-topics/comparators.md

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to