Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

slection sort in php

function selection_sort(&$arr) {
   $n = count($arr);
   for($i = 0; $i < count($arr); $i++) {
      $min = $i;
      for($j = $i + 1; $j < $n; $j++)
         if($arr[$j] < $arr[$min])
            $min = $j;
      $tmp = $arr[$min];
      $arr[$min] = $arr[$i];
      $arr[$i] = $tmp;
   }
	return $arr;
}
Source by www.php.net #
 
PREVIOUS NEXT
Tagged: #slection #sort #php
ADD COMMENT
Topic
Name
8+2 =