Sorted out the quicksort.
Note: Some effort should be put into detecting stack overflow