Posted by blainegarrett on May 30th, 2008 | 1 comment

Insertion Sort In PHP
function insertion_sort4 ($a) {
for ($i = 1; $i < count($a); ++$i) {
/* Assume items before a[i] are sorted. */
/* Pick an number */
$key = $a[$i];
/* Do binary search to find out the point where b is inserted. */
$low = 0; //left
$high = $i; //right
$k = 0;
while ($low - $high = $a[$j]) {
...