PHP and bubble sort

Sorting algorithms are very classical means of manipulating a set of objects to obtain an ordered sequence of these objects. The method we are going to present involves sorting the array in ascending order, using the fact that at each step, all elements in the visited part of the array actually form a sequence of pairs that can be ordered. We don’t just identify the maximum value at each pass, but we also sort the elements of each pair. This may eventually reduce the number of passes required.

Continuer la lecture

PHP and sorting by maximum

Sorting algorithms are classical methods for manipulating a set of objects to obtain an ordered sequence of these objects.

In general, we consider a set of elements of the same class on which a total order is defined, making all these elements comparable for a certain order relation denoted by <. If these objects are numbers, numerical comparison is straightforward.

Continuer la lecture