diff --git a/8.countingSort.md b/8.countingSort.md index efabf9c..d0930cf 100644 --- a/8.countingSort.md +++ b/8.countingSort.md @@ -149,7 +149,11 @@ function countingSort($arr, $maxValue = null) $sortedIndex = 0; foreach ($bucket as $key => $len) { - if ($len !== null) $arr[$sortedIndex++] = $key; + if($len !== null){ + for($j = 0; $j < $len; $j++){ + $arr[$sortedIndex++] = $key; + } + } } return $arr;