3 ms·
Implemented my own quicksort that seems to have better performance than the built-in one. q = (lo, hi) => # highlight range VA.persistHighlight([lo..
by jlnazario 15y ago
Implemented my own quicksort that seems to have better performance than the built-in one.
q = (lo, hi) =>
# highlight range
VA.persistHighlight([lo..hi])
p = VA.get(lo)
l = lo
r = hi
# test pivot position
t = false
while (l < r)
if VA.gt(l,r)
VA.swap(l,r)
t = !t
if t
r--
else
l++
if (l > lo)
q(lo, l - 1)
if (hi > l + 1)
q(l + 1, hi)
q(0,VA.length - 1)