I think you just want: user=> (sort my-map) ([1405960895 20] [1405960927 20] [1405960959 21] [1405960991 20] [1405961023 20] [1405961055 18] [1405961087 23] [1405961119 17] [1405961151 23] [1405961183 19] [1405961215 20] [1405961887 20] [1405961919 20])
sort will call seq on it's argument. The seq from a Map is a sequence of vectors ([k v], ...). The default sorting for the vectors will be the natural sort of the first element, then the second element, and so on. You can also do (-> my-map sort reverse) if you want a DESC sort. marc On Tue, Jul 22, 2014 at 12:24 PM, <empty...@gmail.com> wrote: > Hi, > > I have an unsorted map: > > (def my-map > {1405961887 20, > 1405960895 20, > 1405961919 20, > 1405960927 20, > 1405960959 21, > 1405960991 20, > 1405961023 20, > 1405961055 18, > 1405961087 23, > 1405961119 17, > 1405961151 23, > 1405961183 19, > 1405961215 20} > > I'd like to be able to sort the map by key and then place each value pair > into a vector. > > An attempt at (sorted-map my-map) returns 'No value supplied for key: > {1405961887 20 ....' } > > When I attempt to create a vector from the key/pairs > > (map #(vector %) my-map) > > I receive each key/value in a vector within a vector > > ([[1405961887 20]] > [[1405960895 20]] > [[1405961919 20]] > [[1405960927 20]] > [[1405960959 21]] > [[1405960991 20]] > [[1405961023 20]] > [[1405961055 18]] > [[1405961087 23]] > [[1405961119 17]] > [[1405961151 23]] > [[1405961183 19]] > [[1405961215 20]]) > > My goal is to create a collection of vectors to place in an Incanter > dataset: > > incanter/dataset ["time" "requests"] > [[1405961887 20] > [1405960895 20] > [[1405961919 20]]) > > Many Thanks > > Adrian > > > > > > -- > 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/d/optout. > -- 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/d/optout.