From ce0842ce87a42ce1236dfd38e0b10c9f9804a1b2 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 25 Aug 2023 11:02:26 +0200 Subject: [PATCH] :tada: Add `d/unstable-sort` helper --- common/src/app/common/data.cljc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/common/src/app/common/data.cljc b/common/src/app/common/data.cljc index ba08d0c73c..d3b215c69d 100644 --- a/common/src/app/common/data.cljc +++ b/common/src/app/common/data.cljc @@ -18,6 +18,7 @@ :clj [clojure.edn :as r]) #?(:cljs [cljs.core :as c] :clj [clojure.core :as c]) + #?(:cljs [goog.array :as garray]) [app.common.math :as mth] [clojure.set :as set] [cuerdas.core :as str] @@ -780,6 +781,18 @@ (toString 16) (padStart 2 "0")))) +(defn unstable-sort + ([items] + (unstable-sort compare items)) + ([comp-fn items] + #?(:cljs + (let [items (to-array items)] + (garray/sort items comp-fn) + (seq items)) + :clj + (sort comp-fn items)))) + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; String Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;