| Conditions | 2 |
| Paths | 2 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 2 |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 14 | function sort(array $xss) |
||
| 15 | { |
||
| 16 | 2 | $xss = array_values($xss); |
|
| 17 | |||
| 18 | 2 | if (!has(1, $xss)) { |
|
| 19 | 2 | return $xss; |
|
| 20 | } |
||
| 21 | |||
| 22 | 2 | $pivot = head($xss); |
|
| 23 | 2 | $xs = tail($xss); |
|
| 24 | $left = array_filter($xs, function ($x) use ($pivot) { |
||
| 25 | 2 | return $x < $pivot; |
|
| 26 | 2 | }); |
|
| 27 | $right = array_filter($xs, function ($x) use ($pivot) { |
||
| 28 | 2 | return $x > $pivot; |
|
| 29 | 2 | }); |
|
| 30 | |||
| 31 | 2 | return array_merge(sort($left), [$pivot], sort($right)); |
|
| 32 | } |
||
| 33 |