1<?php
2function quick_sort($my_array)
3 {
4 $loe = $gt = array();
5 if(count($my_array) < 2)
6 {
7 return $my_array;
8 }
9 $pivot_key = key($my_array);
10 $pivot = array_shift($my_array);
11 foreach($my_array as $val)
12 {
13 if($val <= $pivot)
14 {
15 $loe[] = $val;
16 }elseif ($val > $pivot)
17 {
18 $gt[] = $val;
19 }
20 }
21 return array_merge(quick_sort($loe),array($pivot_key=>$pivot),quick_sort($gt));
22}
23