My instructor is very vague also, no one in class understands he teaching method, that why we all were shocked for him to give us a take home exam on something we never covered. He wants us to sort an array with 15 elements in descending order, 1,3,2,4,5,6,7,8,9,10,11,12,13,14,15
He gave us this to turn into the algorithm...
function bubbleSort ($items) { $size = count($items); for ($i=0; $i<$size; $i++) { for ($j=0; $j<$size-1-$i; $j++) { if ($items[$j+1] < $items[$j]) { arraySwap($items, $j, $j+1); } } } return $items;}function arraySwap (&$arr, $index1, $index2) { list($arr[$index1], $arr[$index2]) = array($arr[$index2],$arr[$index1]); }