Well, if you want to sort integers, try using a sorting function. Here is a quick one I just drew up for the bubble sort, maybe it'll work for you.
function bubble_sort($number_array) {
$size = count($number_array);
for ($i = 1; $i < $size; $i++) {
for ($j = $size - 1; $j >= $i; $j--) {
if ($number_array[$j-1] > $number_array[$j]) {
$temp = $number_array[$j-1];
$number_array[$j-1] = $number_array[$j];
$number_array[$j] = $temp;
}
}
}
return $number_array;
}
Just an example, send it an array if integers, it will sort and return them. Like:
$numarray = array(3, 4, 1, 2, 8, 5, 6, 7);
$sorted_array = bubble_sort($numarray);
now, $sorted_array has what you need. Not the BEST answer, of course, but hey remembering stuff from comp sci one always gives me that little taste of nostalgia 🙂
Hope that helps:
Chris King