Php selection sorting _ PHP Tutorial

Source: Internet
Author: User
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 ($...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.