fixed sorting.

This commit is contained in:
Bryce Covert
2019-05-04 08:40:52 -07:00
parent d07367dc19
commit f8d8872131
3 changed files with 35 additions and 19 deletions

View File

@@ -762,6 +762,7 @@
(defn add-sorter-field [q sort-map args]
(println sort-map)
(merge-query q
{:query {:find ['?sorter]
:where (sort-map
@@ -774,9 +775,18 @@
(= (:asc args) false) (reverse)))
(defn apply-sort-2 [args results ]
(let [comparator (if (= (:asc args) false)
(fn [x y] (compare y x))
(fn [x y] (compare x y)))]
(let [comparator
(if (:sort-by args)
(fn [[x & rest-x] [y & rest-y]]
(let [base-sort (if (:asc args)
(compare x y)
(compare y x))]
(if (= 0 base-sort)
(compare (vec rest-y) (vec rest-x))
base-sort)))
(fn [x y]
(compare y x)))]
(sort comparator results )))
(defn apply-pagination [args results]