Skip to content

Commit 34676b3

Browse files
committed
Changes the indentation in shellsort
1 parent 28712ff commit 34676b3

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

src/sorting/shellsort/shellsort.js

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
/**
2-
* Shellsort
3-
*
4-
* Shellsort uses the gaps 701, 301, 132, 57, 23, 10, 4, 1 and uses insertion sort
5-
* to sort the sub-arrays which match for the different gaps.
6-
*/
7-
var shellsort = (function () {
1+
(function (exports) {
2+
3+
/**
4+
* Shellsort
5+
*
6+
* Shellsort uses the gaps 701, 301, 132, 57, 23, 10, 4, 1 and uses insertion sort
7+
* to sort the sub-arrays which match for the different gaps.
8+
*/
9+
var shellSort = (function () {
810

911
var gaps = [701, 301, 132, 57, 23, 10, 4, 1];
1012

@@ -16,19 +18,23 @@ var shellsort = (function () {
1618
* @return {array} Sorted array
1719
*/
1820
return function (array) {
19-
var gap, current;
21+
var gap, current;
2022

21-
for (var k = 0; k < gaps.length; k += 1) {
22-
gap = gaps[k];
23-
for (var i = gap; i < array.length; i += gap) {
24-
current = array[i];
25-
for (var j = i; j >= gap && array[j - gap] > current; j -= gap) {
26-
array[j] = array[j - gap];
27-
}
28-
array[j] = current;
29-
}
23+
for (var k = 0; k < gaps.length; k += 1) {
24+
gap = gaps[k];
25+
for (var i = gap; i < array.length; i += gap) {
26+
current = array[i];
27+
for (var j = i; j >= gap && array[j - gap] > current; j -= gap) {
28+
array[j] = array[j - gap];
29+
}
30+
array[j] = current;
3031
}
31-
return array;
32+
}
33+
return array;
3234
};
3335

34-
}());
36+
}());
37+
38+
exports.shellSort = shellSort;
39+
40+
}(typeof exports === 'undefined' ? window : exports));

0 commit comments

Comments
 (0)