Skip to content

Commit 74d1acc

Browse files
author
AndreyGeonya
committed
add 3-way-quicksort jsdoc
1 parent 15ded21 commit 74d1acc

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

doc-config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"./src/others/",
1515
"./src/searching/",
1616
"./src/sets/",
17-
"./src/shuffle/"
17+
"./src/shuffle/",
18+
"./src/sorting/"
1819
],
1920
"includePattern": ".+\\.js(doc)?$",
2021
"excludePattern": "docs"

src/sorting/3-way-string-quicksort.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
(function (exports) {
22
'use strict';
33

4-
/**
5-
* Effective inplace string sorting algorithm.
6-
* The algorithm is NOT stable.
7-
*/
84
var quicksort = (function () {
95

106
function charAt(str, i) {
@@ -48,6 +44,21 @@
4844
quicksort(arr, highPointer + 1, hi, d);
4945
}
5046

47+
/**
48+
* Effective inplace string sorting algorithm.
49+
* Algorithm is NOT stable.
50+
*
51+
* @example
52+
*
53+
* var sort = require('path-to-algorithms/src/sorting'+
54+
* '/3-way-string-quicksort').quicksort;
55+
* console.log(sort(['bb', 'aa', 'cc'])); // [ 'aa', 'bb', 'cc' ]
56+
*
57+
* @public
58+
* @module sorting/3-way-string-quicksort
59+
* @param arr {Array} array which should be sorted.
60+
* @return {Array} Sorted array.
61+
*/
5162
return function sort(arr) {
5263
quicksort(arr, 0, arr.length - 1, 0);
5364
return arr;
@@ -56,4 +67,4 @@
5667

5768
exports.quicksort = quicksort;
5869

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

0 commit comments

Comments
 (0)