Php selects sorting. [Php]? Php selects sort from small to large sort date_default_timezone_set (AisaShanghai); $ selectarray (); for ($ i0; $ i500; $ I ++) {$ select [$ I] rand (0,3000);} functionselectsort ($ a [php]
// Select sorting
// Sort data in ascending order
// Date_default_timezone_set ('aisa/Shanghai ');
$ Select = array ();
For ($ I = 0; I I <500; $ I ++)
{
$ Select [$ I] = rand (0,3000 );
}
Function selectsort (& $ arr)
{
$ Temp = 0;
For ($ I = 0; $ I {
$ Minval = $ arr [$ I]; // each time you think that the number of I is the minimum value
$ Minindex = $ I;
For ($ j = $ I + 1; $ j {
// The current value is not the minimum value.
If ($ minval> $ arr [$ j])
{
$ Minval = $ arr [$ j];
$ Minindex = $ j;
}
}
// Exchange after the inner for loop ends. this is the place where the bubble sorting is superior.
$ Temp = $ arr [$ I];
$ Arr [$ I] = $ arr [$ minindex];
$ Arr [$ minindex] = $ temp;
}
}
Selectsort ($ select );
Print_r ($ select );
// Date_default_timezone_set ('aisa/Shanghai ');
?>
[Php]
Why? Php // select sort // sort from small to large // date_default_timezone_set (Aisa/Shanghai); $ select = array (); for ($ I = 0; $ i500; $ I ++) {$ select [$ I] = rand (0,3000);} function selectsort ($...