Fork me on GitHub
#cljs-dev
<
2019-09-02
>
Roman Liutikov15:09:53

What is the reason sort is implemented as to-array -> garray/stableSort -> seq? Is it still faster than doing sorting in cljs?

favila18:09:01

This is also what Clojure does

favila18:09:42

Modern js guarantees stable sort now, so could use native array sort instead of stableSort now (saves extra allocation I think, I don’t remember the impl exactly)

favila18:09:33

What are you thinking of that might be better?

thheller18:09:49

how else would you sort? you always go to an array and sort that in a mutable way. even doing it with transients would probably be a lot slower

thheller18:09:17

* Runtime: Same as <code>Array.prototype.sort</code>, plus an additional
 * O(n) overhead of copying the array twice.

thheller18:09:16

would be interesting to see how much that overhead is in practice