Skip to content

Commit 10fdeb4

Browse files
committed
User boolean instead of integer in bubble sort check flag
1 parent 6cfc039 commit 10fdeb4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

algorithms/sorting/bubble_sort.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var bubbleSort = function (a, comparatorFn) {
2929
var comparator = new Comparator(comparatorFn);
3030
var n = a.length;
3131
var bound = n - 1;
32-
var check = 0;
32+
var check = false;
3333
for (var i = 0; i < n - 1; i++) {
3434
var newbound = 0;
3535
for (var j = 0; j < bound; j++) {
@@ -38,10 +38,10 @@ var bubbleSort = function (a, comparatorFn) {
3838
a[j] = a[j + 1];
3939
a[j + 1] = tmp;
4040
newbound = j;
41-
check = 1;
41+
check = true;
4242
}
4343
}
44-
if (0 === check)
44+
if (!check)
4545
return a;
4646
bound = newbound;
4747
}

0 commit comments

Comments
 (0)