<?php function bubble($list, $cycle = 0) { $stop = count($list) - $cycle; if ($stop == 0) return $list; for ($i = 0; $i < $stop; $i++) { $next = $i + 1; if (isset($list[$next])) { $temp = $list[$i]; if ($list[$next] < $list[$i]) { $list[$i] = $list[$next]; $list[$next] = $temp; } } } $cycle++; return bubble($list, $cycle); } ?>