Skip to content

Commit 7db8f55

Browse files
committed
fix: modify fail 🔀
1 parent e8f96d9 commit 7db8f55

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

package/Sort/QuickSort.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212
* 递归地(recursive)把小于基准值元素的子数列和大于基准值元素的子数列排序
1313
*
1414
* @param array $container
15-
* @return array|void
15+
* @return mixed
1616
*/
1717
function QulickSort( array $container ){
1818
$count = count( $container );
19-
if( $count <= 1 ) return;
19+
if( $count <= 1 ) {
20+
return $container;
21+
}
2022
$left = $right = [];
2123
for ( $i =0; $i<$count-1;$i++ ){
2224
if( $container[$i] < $container[0] ){
@@ -26,7 +28,7 @@ function QulickSort( array $container ){
2628
}
2729
}
2830
$left = QulickSort($left); $right = QulickSort($right);
29-
return array_merge($left,[$container[0],$right]);
31+
return array_merge($left,[$container[0]],$right);
3032
}
3133

3234
var_dump( QulickSort([4,21,41,2,53,1,213,31,21,423]) );

0 commit comments

Comments
 (0)