How would I express the speed of the following sort algorithm? I know bubblesort is n^n (er, I mean n^2...as someone pointed out below). In the following the array decreases each time you call it recursively. thanks. ------------------------------------------------- $myarray = array("21","4","8","8","1","2","19","21"); mysort($myarray); function mysort($myarray,$sorted = null){ if(!isset($sorted)){ $sorted = array(); } $lowest = $myarray[0]; $lowindex = 0; for($x = 1;$x < count($myarray);$x++){ if($myarray[$x] < $lowest){ $lowest = $myarray[$x]; $lowindex = $x; } } $sorted[] = $lowest; array_splice($myarray,$lowindex,1); if(count($myarray) > 1){ echo "calling recursively \n"; mysort($myarray,$sorted); } else if(count($myarray) == 1){ $sorted[] = $myarray[0]; $arraystr = print_r($sorted,true); echo "sorting finished. Array is $arraystr \n"; return; } }