Hey all,

I think I've found a bug in `sorted-map-by`, as shown by the below code:

```
(ns app.core-test
  (:require
   [cljs.test :refer (deftest is)]
   [clojure.string :as st]))

(prn *clojurescript-version*)  ;; "1.10.914"

(defn single-row [result-row]
  {:input (:input result-row)
   (keyword (st/join [(name (:biomarker result-row)) "-datapoints"])) 
(:datapoints result-row)})

(defn sort-map [m]
  ; Sort row so that :input is first, then put this rest in alphabetical 
order
  (into (sorted-map-by #(if (= % :input) "aaaaa" (name %))) m))

(defn get-per-input-row [same-input-results]
  ; Calling sort-map twice here resolves the problem.
  (sort-map (reduce merge (map single-row same-input-results))))

(defn make-per-input-results
  [results]
  (let [rows-by-input (group-by :input results)]
    (map get-per-input-row (vals rows-by-input))))

(deftest test-bad-map-sorting
  (is (= '({:input 1 :a-datapoints 5}
           {:input 2 :a-datapoints 5}
           {:input 3 :b-datapoints 5}
           {:input 4 :b-datapoints 5})
         (make-per-input-results
          [{:input 1 :biomarker :a :datapoints 5}
           {:input 2 :biomarker :a :datapoints 5}
           {:input 3 :biomarker :b :datapoints 5}
           {:input 4 :biomarker :b :datapoints 5}]))))
```

The testcase fails, when I would expect it to succeed.  I tried posting 
this on the cljs JIRA as a bug, but I don't have permission, so I thought 
I'd post it here instead.  Anyone want to try reproducing this and posting 
on the JIRA if you can reproduce it?

 - Kovas

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojurescript/7eedfcb0-acff-496c-b332-11589f7e9582n%40googlegroups.com.

Reply via email to