Implement a general purpose quicksort algorithm

The old implementations of quicksort are removed.
Use wrappers in rnd functions to check for nil values