// from right look for element not greater than the pivot
            }
            if ($rightPos > $leftPos) {
                $this->swap($array, $leftPos, $rightPos);
                // if the left index is still smaller than the right index, swap the corresponding elements
            }
        }
        // after the indices have crossed, swap the last element in the left partition with the pivot
        $this->swap($array, $start, $rightPos);
        // quicksort the left partition
        $this->quickSort($array, $start, $rightPos - 1);
        // quicksort the right partition
        $this->quickSort($array, $rightPos + 1, $end);
    }
    /**
     * Swaps index values by position
     *
     * @param array
     * @param index1
     * @param index2
     */
    public function swap(&$array, $index1, $index2)
    {
        $temp = $array[$index1];
        $array[$index1] = $array[$index2];
        $array[$index2] = $temp;
    }
}
$alg = new AlgorithmTest();
$alg->main();