Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit de706f1

Browse files
committed
Update recursive insertion sort
1 parent 180ac8e commit de706f1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/sorting/recursive-insertionsort.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
*/
2828
function recursiveInsertionSort(array, cmp, max) {
2929
cmp = cmp || compare;
30-
if (max <= 0) {
31-
return array;
32-
}
3330
if (max === undefined) {
3431
max = array.length - 1;
3532
}
33+
if (max <= 0) {
34+
return array;
35+
}
3636
recursiveInsertionSort(array, cmp, max - 1);
3737
for (var i = max - 1, current = array[max];
3838
i >= 0 && cmp(current, array[i]) < 0; i -= 1) {

0 commit comments

Comments
 (0)