fixed sorting.
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user