diff --git a/CHANGES.md b/CHANGES.md index 97ee2f2..7ea646a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ * Added low-level `richnav` macro for creating navigators with full flexibility * Bug fix: multi-path and if-path now work properly with value collection * Bug fix: END, BEGINNING, FIRST, LAST, and MAP-VALS now work properly on nil +* Bug fix: ALL and MAP-VALS now maintain the comparator of sorted maps ## 0.11.2 * Renamed com.rpl.specter.transient namespace to com.rpl.specter.transients to eliminate ClojureScript compiler warning about reserved keyword diff --git a/src/clj/com/rpl/specter/impl.cljx b/src/clj/com/rpl/specter/impl.cljx index d6a7a23..b27c8a1 100644 --- a/src/clj/com/rpl/specter/impl.cljx +++ b/src/clj/com/rpl/specter/impl.cljx @@ -861,7 +861,7 @@ #+clj clojure.lang.PersistentTreeMap #+cljs cljs.core/PersistentTreeMap (all-transform [structure next-fn] - (non-transient-map-all-transform structure next-fn (sorted-map)) + (non-transient-map-all-transform structure next-fn (empty structure)) ) #+clj clojure.lang.PersistentHashMap #+cljs cljs.core/PersistentHashMap @@ -963,7 +963,7 @@ #+clj clojure.lang.PersistentTreeMap #+cljs cljs.core/PersistentTreeMap (map-vals-transform [structure next-fn] - (map-vals-non-transient-transform structure (sorted-map) next-fn) + (map-vals-non-transient-transform structure (empty structure) next-fn) ) #+clj clojure.lang.PersistentHashMap #+cljs cljs.core/PersistentHashMap diff --git a/test/com/rpl/specter/core_test.cljx b/test/com/rpl/specter/core_test.cljx index cc485b2..fe82058 100644 --- a/test/com/rpl/specter/core_test.cljx +++ b/test/com/rpl/specter/core_test.cljx @@ -1295,3 +1295,9 @@ (select [(s/multi-path (s/collect-one :a) (s/collect-one :c)) :b] {:a 1 :b 2 :c 3}))) ) + +(deftest sorted-map-by-transform + (let [amap (sorted-map-by > 1 10 2 20 3 30)] + (is (= [3 2 1] (keys (transform s/MAP-VALS inc amap)))) + (is (= [3 2 1] (keys (transform [s/ALL s/LAST] inc amap)))) + ))