This quicksort implements the basic recursive algorithm with three improvements. The first improvement is choosing the pivot based on the median of three values in the list to be sorted. This minimizes the chances of a worst case scenario. The second improvement speeds up the algorithm by termination when subfiles of a certain size are reached. At that point continuing the recursion is not as effective as calling insertion sort on the almost sorted list. The last improvement protects against worst case behavior if there are large numbers of duplicates on the list by partitioning three ways instead of two: all items that are smaller than the pivot, all items that are equal to the pivot, and all items that are greater than the pivot.
One more improvement can be made to bring this implementation to production quality. It must be generalized for any type by accepting pointers to void and a comparison function.
one might also remove tail recursion, but on modern machines this isn't nearly the issue that it once was.