I had always assumed that vectors were sorted lexicographically.  In
other words, you sort on the first element, and then refine by the
second element, and so on.  I was surprised tonight to discover that
is not the case.

> (compare "abc" "b")        ; Strings are compared lexicographically
-1
> (compare (vec "abc") (vec "b"))    ; Vectors are not
1

It turns out that shorter vectors are always considered to be "less
than" longer vectors.  Lexicographic behavior only kicks in among
vectors of the same length.  Not at all what I expected, so I wanted
to make sure everyone knew about this behavior.

-- 
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