simplify sorting

This commit is contained in:
Bryce
2024-04-10 14:48:47 -07:00
parent 1493b03ba3
commit 65be50cf9f
7 changed files with 104 additions and 81 deletions

View File

@@ -601,7 +601,8 @@
(:sort args)))
(defn apply-sort-3 [args results]
(let [sort-bys (conj (:sort args)
(let [sort-bys (conj (into [] (:sort args))
{:sort-key "default" :asc (if (contains? args :default-asc?)
(:default-asc? args)
true)})
@@ -609,16 +610,17 @@
comparator (fn [xs ys]
(reduce
(fn [_ i]
(let [comparison (if (:asc (nth sort-bys i))
(compare (nth xs i) (nth ys i))
(compare (nth ys i) (nth xs i)))]
(if (not= 0 comparison)
(reduced comparison)
0)))
0
(range length)))]
(sort comparator results )))
(sort comparator results)))
(defn apply-pagination-raw [args results]
{:entries (->> results