good s orting across the board.
This commit is contained in:
@@ -762,7 +762,6 @@
|
||||
|
||||
|
||||
(defn add-sorter-field [q sort-map args]
|
||||
(println sort-map)
|
||||
(merge-query q
|
||||
{:query {:find ['?sorter]
|
||||
:where (sort-map
|
||||
@@ -774,19 +773,21 @@
|
||||
sort-fn (sort-by sort-fn)
|
||||
(= (:asc args) false) (reverse)))
|
||||
|
||||
(defn apply-sort-2 [args results ]
|
||||
(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)))]
|
||||
(defn apply-sort-2 [args default-sort results ]
|
||||
(let [sort-bys (if (:sort-by args)
|
||||
(conj (seq default-sort) (if (:asc args)
|
||||
:asc
|
||||
:desc))
|
||||
(seq default-sort))
|
||||
comparator (fn [xs ys]
|
||||
(or (->> (map vector sort-bys xs ys)
|
||||
(map (fn [[asc x y]]
|
||||
(if (= :asc asc)
|
||||
(compare x y)
|
||||
(compare y x))))
|
||||
(drop-while #(= 0 %))
|
||||
first)
|
||||
0))]
|
||||
(sort comparator results )))
|
||||
|
||||
(defn apply-pagination [args results]
|
||||
|
||||
Reference in New Issue
Block a user