Implements Quick sort