note 102997 added to function.sort

From: Date: Sat, 19 Mar 2011 05:46:00 +0000
Subject: note 102997 added to function.sort
Groups: php.notes 
Request: Send a blank email to php-notes+get-177998@lists.php.net to get a copy of this message
Sorting some numbers <?php /* * Created By Ayham Alsuleman in 25\10\2010 */ function NumberSort($array){ //check the inputs if (is_array($array)){ //get array one by one for ($i=0 ; $i < count($array) ; $i++){ //compare each value with other values in array for ($j=$i+1;$j < count($array); $j++){ //if the current calue bigger than other one, then replace values if ($array[$i] > $array[$j]){ //replacing $tmp = $array[$i]; $array[$i] = $array[$j]; $array[$j] = $tmp; } } } return $array; }else{ return false; } } //Example $array = array (2,3,54,56,4,4,23,6,7,100,23,5,63); print '<pre>'; print_r(NumberSort($array)); print '</pre>'; ?> ---- Server IP: 69.147.83.197 Probable Submitter: 82.137.200.9 ---- Manual Page -- http://www.php.net/manual/en/function.sort.php Edit -- https://master.php.net/note/edit/102997 Del: integrated -- https://master.php.net/note/delete/102997/integrated Del: useless -- https://master.php.net/note/delete/102997/useless Del: bad code -- https://master.php.net/note/delete/102997/bad+code Del: spam -- https://master.php.net/note/delete/102997/spam Del: non-english -- https://master.php.net/note/delete/102997/non-english Del: in docs -- https://master.php.net/note/delete/102997/in+docs Del: other reasons-- https://master.php.net/note/delete/102997 Reject -- https://master.php.net/note/reject/102997 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#177998) next »