On Nov 20, 2012, at 11:04 AM, Alan Malloy wrote: > On Tuesday, November 20, 2012 10:29:18 AM UTC-8, Andy Fingerhut wrote: > > On Nov 20, 2012, at 10:12 AM, Mark Engelberg wrote: > > > Clojure's sorted collections must be provided with a sorting function where > > items "tie" if and only if they are equal. > > > > (sorted-set-by #(compare [(second %) %] [(second %2) %2]) [:a 1] [:b 1] [:c > > 1])) > > Mark, I like the brevity of this way of writing comparison functions with tie > breakers, and see that it would extend well to multiple sort keys, and > ascending or descending order on each key can be chosen independently. > > My question is perhaps of the > is-the-number-of-angels-that-can-dance-on-the-head-of-a-pin-finite-or-infinite > kind. > > Does Clojure promise anywhere in its documentation that it compares vectors > and sequences in lexicographic order? > > > I hope not, because that's not what it does! Sequences don't implement > Comparable at all, so unless you supply a comparator they can't be sorted. > And vectors are compared first by length; only if they have the same length > are their elements considered for a lexicographical comparison.
Thanks for the corrections. Then my question is still: "Would it be good for Clojure to document and promise this comparison behavior?" If not for all cases, at least for equal-length vectors being compared lexicographically? Andy -- 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