Skip to content

Commit 2dc73ba

Browse files
author
AndreyGeonya
committed
shellsort jsdoc
1 parent 9239afa commit 2dc73ba

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/sorting/recursive-insertionsort.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* @param {Number} max Optional. Index of the element which place
2525
* we should find in the current function call.
2626
* @return {Array} Sorted array.
27-
*/
27+
*/
2828
function recursiveInsertionSort(array, cmp, max) {
2929
cmp = cmp || compare;
3030
if (max <= 0) {

src/sorting/shellsort.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,27 @@
55
return a - b;
66
}
77

8-
/**
9-
* Shellsort
10-
*
11-
* Shellsort uses the gaps 701, 301, 132, 57, 23, 10, 4, 1 and uses
12-
* insertion sort to sort the sub-arrays which match for the different gaps.
13-
*/
148
var shellSort = (function () {
159

1610
var gaps = [701, 301, 132, 57, 23, 10, 4, 1];
1711

1812
/**
19-
* Shellsort which uses the gaps in the lexical scope of the IIFE.
13+
* Shellsort which uses the gaps 701, 301, 132, 57, 23, 10, 4, 1 and
14+
* insertion sort to sort sub-arrays which match for the different gaps.
15+
*
16+
* @example
17+
*
18+
* var sort = require('path-to-algorithms/src/' +
19+
* 'sorting/shellsort').shellSort;
20+
* console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ]
2021
*
2122
* @public
22-
* @param {array} array Array which should be sorted
23-
* @return {array} Sorted array
23+
* @module sorting/shellsort
24+
* @param {Array} array Input array.
25+
* @param {Function} cmp Optional. A function that defines an
26+
* alternative sort order. The function should return a negative,
27+
* zero, or positive value, depending on the arguments.
28+
* @return {Array} Sorted array.
2429
*/
2530
return function (array, cmp) {
2631
cmp = cmp || compare;

0 commit comments

Comments
 (0)