Skip to content

Commit 9239afa

Browse files
author
AndreyGeonya
committed
add selection sort jsdoc
1 parent 35c0cdb commit 9239afa

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

‎src/sorting/selectionsort.js‎

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

88
/**
9-
* Selection sort. It's complexity is O(n^2)
9+
* Selection sort.<br><br>
10+
* Time complexity: O(N^2).
11+
*
12+
* @example
13+
*
14+
* var sort = require('path-to-algorithms/src/sorting/'+
15+
* 'selectionsort').selectionSort;
16+
* console.log(sort([2, 5, 1, 0, 4])); // [ 0, 1, 2, 4, 5 ]
1017
*
1118
* @public
12-
* @param {array} array Array to be sorted
13-
* @return {array} The sorted array
19+
* @module sorting/selectionsort
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
var selectionSort = function (array, cmp) {
1627
cmp = cmp || compare;
@@ -35,4 +46,4 @@
3546

3647
exports.selectionSort = selectionSort;
3748

38-
}(typeof exports === 'undefined' ? window : exports));
49+
})(typeof window === 'undefined' ? module.exports : window);

0 commit comments

Comments
 (0)