/** * Quick sort: Unstable, time complexity best O (nlogn) worst time O (n^2) * Quick Sort is an essential improvement on bubble sorting. Its basic idea is that after a scan, the length of the sequencing sequence can be significantly reduced. In a bubbling sort, a scan can only ensure that the number of maximum values is moved to the correct position, while the length of the sequence to be sorted may be reduced by only 1. Quick sort by a scan, you can make sure that the number of the left is smaller than it is, and the number on the right is larger than it. It then uses the same method to manipulate the left and right sides of the number until there is only one element to the left of the datum point. * @param Array $arr * @return Array */ functionfastsort(array $arr){if(Count ($arr) >1){$num=$arr[0];$arrSmall= [];$arrBig= [];foreach($arr as$item){if($item>$num){$arrBig[] =$item; }ElseIf($item<$num){$arrSmall[] =$item; } }$arrSmall= Fastsort ($arrSmall);$arrBig= Fastsort ($arrBig);$arr= Array_merge ($arrSmall,[$num],$arrBig); }Else{return$arr; }return$arr;}
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the fast sort of PHP implementation, including the fast sorting, PHP content, I hope that the PHP tutorial interested in a friend helpful.