Emmanuel Benoist Home Page

Exercise: Base Syntax of PHP I

Illustrating sorts

PHP provides many sorting functions, efficient and simple to use.
Unfortunately, these method are not well suited for the demonstration in front of the students. Therefore, it would be necessary to design a class which would show each step of the sorting process. This can be done within a web page as demonstrated in Bubble Sort and Quick sort demonstration.
For the bubble sort algorithm, you will need the following function:
   count($arr) // Gives the number of items in the array $arr
If you are a skilled PHP programmer, you will program quick sort (see the algorithmic course for more details). You can program the recursive version, which is easier to program.

Solution