Skip to content

Commit 0efe8fe

Browse files
namenumfikes
authored andcommitted
CLJS-2959: sort and sort-by should retain meta
1 parent 0ea117b commit 0efe8fe

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/main/cljs/cljs/core.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2457,7 +2457,7 @@ reduces them without incurring seq initialization"
24572457
(let [a (to-array coll)]
24582458
;; matching Clojure's stable sort, though docs don't promise it
24592459
(garray/stableSort a (fn->comparator comp))
2460-
(seq a))
2460+
(with-meta (seq a) (meta coll)))
24612461
())))
24622462

24632463
(defn sort-by

src/test/cljs/cljs/core_test.cljs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,10 @@
17381738
(is (= (symbol (->Var nil 'bar/foo nil)) 'bar/foo))
17391739
(is (thrown? js/Error (symbol 1))))
17401740

1741+
(deftest test-cljs-2959
1742+
(is (= {:a true} (meta (sort (with-meta (range 10) {:a true})))))
1743+
(is (= {:a true} (meta (sort-by :a (with-meta (seq [{:a 5} {:a 2} {:a 3}]) {:a true}))))))
1744+
17411745
(deftest test-cljs-2991
17421746
(let [o (js-obj)]
17431747
(is (object? o))

0 commit comments

Comments
 (0)