PHP Associative Array Quick Sort method, PHP associative array
This paper describes the method of fast ordering of associative arrays in PHP. Share to everyone for your reference. Specific as follows:
<?php function qsort ($a, $f) {Qsort_do (& $a, 0,count ($a)-1, $f),} function Qsort_do ($a, $l, $r, $f) {if ($l < $r) { C0/>qsort_partition (& $a, $l, $r,& $lp,& $rp, $f); QSORT_DO (& $a, $l, $LP, $f); QSORT_DO (& $a, $RP, $r, $f); } } function Qsort_partition ($a, $l, $r, $LP, $RP, $f) {$i = $l +1; $j = $l +1; while ($j <= $r) { if ($f ($a [$j], $a [$l])) { $tmp = $a [$j]; $a [$j] = $a [$i]; $a [$i] = $tmp; $i + +; } $j + +; } $x = $a [$l]; $a [$l] = $a [$i-1]; $a [$i-1] = $x; $LP = $i-2; $RP = $i;}? >
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/985262.html www.bkjia.com true http://www.bkjia.com/PHPjc/985262.html techarticle PHP Associative array Quick Sort method, PHP associative array This paper describes the method of fast ordering of associative arrays in PHP. Share to everyone for your reference. Specific as follows: Php function QSO ...