function qsort(li, reverse=false) {
    if (li.length === 0) return []
    const [x, ...xs] = li
    const ys = xs.filter(y => y <= x)
    const zs = xs.filter(z => z > x)
    return (reverse) 
        ? [...qsort(zs, reverse), x, ...qsort(ys, reverse)]
        : [...qsort(ys, reverse), x, ...qsort(zs, reverse)]       
}

const li = [6,2,8,3,1,9,5,4,0,7]
console.log(li)
console.log(qsort(li))
console.log(qsort(li, true))

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: