Order of elements in a map

18 views
Skip to first unread message

Prathamesh Sonpatki

unread,
Apr 8, 2013, 12:08:25 AM4/8/13
to clj-...@googlegroups.com
Hi,

I was trying maps in REPL and found some interesting behavior.

user> {:name "prathamesh" :lang "clojure"}
{:name "prathamesh", :lang "clojure"}

user> {:name "prathamesh" :lang "clojure" :age 22}
{:age 22, :name "prathamesh", :lang "clojure"}

Why the order of elements changed in second example?

Baishampayan Ghose

unread,
Apr 8, 2013, 12:16:31 AM4/8/13
to clj-...@googlegroups.com

hash-maps don't have any guaranteed ordering. If you want ordering you need to use a sorted-map. ~BG

Sent from phone. Please excuse brevity.

--
You received this message because you are subscribed to the Google Groups "Clojure Users Group Pune" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clj-pune+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/clj-pune?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages