/ Published in: PHP
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
/*
sortIntegers()
---
Uses the "bubble sort" algorithm to sort an array of
integers. PHP's sorting functions are fine, so this
function is merely to demonstrate how it could be done.
*/
function sortIntegers($x)
{
for ($i=0; $i<$count; $i++)
{
if ($x[$i]<$x[$i+1]) continue;
$x = sortIntegers($x);
}
return $x;
}
// Example
$sorted = sortIntegers($integers);
Comments
 Subscribe to comments
                    Subscribe to comments
                
                