Custom implementation of quicksort in C++