[CLJ-1382] Vector sort order should be specified sufficiently to embrace sort-by-juxt Created: 13/Mar/14 Updated: 15/Mar/14 Resolved: 15/Mar/14
|Affects Version/s:||Release 1.5|
|Labels:||data-structures, documentation, idiom|
Vectors of equal length sort in a way that seems natural – by
This property enables a blisteringly wonderful idiom for sorting
The sort-by-juxt idiom was described on briancarper.net, where it
Such lore gives it the odor of respectability, but the sort-by-juxt
The vector specification should be bolstered with enough traits of
|Comment by Alex Miller [ 13/Mar/14 9:52 PM ]|
I don't understand what this ticket is asking for.
|Comment by Andy Fingerhut [ 13/Mar/14 10:32 PM ]|
It sounds like he is asking that the doc of clojure.core/compare say that vectors of equal length are compared in lexicographic order.
|Comment by Phill Wolf [ 15/Mar/14 1:07 PM ]|
"(sort-by (juxt" relies on a feature of vectors that the Clojure documentation does not guarantee. But using juxt in this way is part of the cultural fabric and helps make concise programs that "read like a definition" of the problem, to quote Halloway in "Programming Clojure". Therefore, let's document the sort order of equal-length vectors. I looked for this information on the Data Structures page, which has a section on vectors.
|Comment by Alex Miller [ 15/Mar/14 11:11 PM ]|
I added a line to the Vectors section on the Data Structures (http://clojure.org/data_structures) page: "Vectors are compared first by length, then each element is compared in order."