How it works...

The crux of the preceding code lies in the following line:

    qsort ys ++ [x] ++ qsort zs

In the preceding statement, notice the following:

At the outset, the implementation looks like an exact qsort. However, a closer look reveals that we use the filter function to partition the elements in the list. The filter function is an O(n) function. In the worst case, the performance of our algorithm will be O(n2), a far cry from the qsort specifications.