Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a05e7d9

Browse files
committed
1 parent 8311f6c commit a05e7d9

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

src/sorting/mergesort.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,15 @@
1313
*
1414
* @public
1515
* @module sorting/mergesort
16-
* @param {array} array The array which should be sorted
17-
* @param {Function} cmp Compares two items in an array
18-
* @param {number} start Left side of the subarray
19-
* @param {number} end Right side of the subarray
20-
* @returns {array} Array with sorted subarray
16+
* @param {Array} array The array which should be sorted.
17+
* @param {Function} cmp Compares two items in an array.
18+
* @param {Number} start Left side of the subarray.
19+
* @param {Number} end Right side of the subarray.
20+
* @returns {Array} Array with sorted subarray.
21+
*
22+
* @example
23+
* var array = [2, 4, 1, 5, 6, 7];
24+
* mergeSort(array); // [1, 2, 4, 5, 6, 7]
2125
*/
2226
function mergeSort(array, cmp, start, end) {
2327
cmp = cmp || compare;
@@ -39,12 +43,18 @@
3943
*
4044
* @public
4145
* @module sorting/mergesort/merge
42-
* @param {array} array The array which subarrays should be sorted
43-
* @param {number} start The start of the first subarray.
46+
* @param {Array} array The array which subarrays should be sorted.
47+
* @param {Number} start The start of the first subarray.
4448
* This subarray is with end middle - 1.
45-
* @param {number} middle The start of the second array
46-
* @param {number} end end - 1 is the end of the second array
47-
* @returns {array} The array with sorted subarray
49+
* @param {Number} middle The start of the second array.
50+
* @param {Number} end end - 1 is the end of the second array.
51+
* @returns {Array} The array with sorted subarray.
52+
*
53+
* @example
54+
* var array = [1, 2, 3, 1, 4, 5, 6]
55+
* merge(array, function (a, b) { // [1, 1, 2, 3, 4, 5, 6]
56+
* return a - b;
57+
* }, 0, 4, 7);
4858
*/
4959
mergeSort.merge = function (array, cmp, start, middle, end) {
5060
var left = [];

0 commit comments

Comments
 (0)