Skip to content

Commit e4589d7

Browse files
author
AndreyGeonya
committed
insertionsort jsdoc
1 parent ef68c0a commit e4589d7

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/sorting/insertionsort.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,22 @@
66
}
77

88
/**
9-
* Insertionsort algorithm. It's complexity is O(n^2).
9+
* Insertionsort algorithm.
10+
* Time complexity: O(N^2).
11+
*
12+
* @example
13+
*
14+
* var sort = require('path-to-algorithms/src' +
15+
* '/sorting/insertion-sort').insertionSort;
16+
* console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ]
1017
*
1118
* @public
12-
* @param {array} array Input array
13-
* @returns {array} array Sorted array
19+
* @module sorting/insertionsort
20+
* @param {Array} array Input array.
21+
* @param {Function} cmp Optional. A function that defines an
22+
* alternative sort order. The function should return a negative,
23+
* zero, or positive value, depending on the arguments.
24+
* @return {Array} Sorted array.
1425
*/
1526
function insertionSort(array, cmp) {
1627
cmp = cmp || compare;

0 commit comments

Comments
 (0)