-
-
Notifications
You must be signed in to change notification settings - Fork 129
Open
Labels
Description
Hello! I'm using Conjure to work on a project with both Clojure and ClojureScript, and I've noticed a strange discrepancy in evaluating sorted maps:
(def us-states
{"AK" "Alaska"
"AL" "Alabama"
"AR" "Arkansas"
"AZ" "Arizona"
"CA" "California"
"CO" "Colorado"
"CT" "Connecticut"
"DE" "Delaware"
"FL" "Florida"})
(def reverse-states
(into (sorted-map) us-states))
In ClojureScript (with shadow-cljs), evaluating this code, and then evaluating reverse-states
on its own, results in this output in the Conjure buffer — clearly not in sorted order:
{"AK" "Alaska",
"FL" "Florida",
"CT" "Connecticut",
"AR" "Arkansas",
"AL" "Alabama",
"CA" "California",
"DE" "Delaware",
"AZ" "Arizona",
"CO" "Colorado"}
However, (prn reverse-states)
does return a string representation with the keys in sorted order, which is why I suspect this is an issue in Conjure.
Additionally:
- Removing an element from the original map results in the order being retained when evaluated. It only seems to be an issue for maps with more than 8 elements.
- Following the same steps in Clojure prints the map in sorted order, for any number of elements.
- Creating and evaluating the map directly with
(sorted-map "AK" "Alaska" ...)
doesn't seem to have this issue
Would love some insight into this since it made me mistakenly believe that my code was broken for a while :)