|
13 | 13 | *
|
14 | 14 | * @public
|
15 | 15 | * @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] |
21 | 25 | */
|
22 | 26 | function mergeSort(array, cmp, start, end) {
|
23 | 27 | cmp = cmp || compare;
|
|
39 | 43 | *
|
40 | 44 | * @public
|
41 | 45 | * @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. |
44 | 48 | * 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); |
48 | 58 | */
|
49 | 59 | mergeSort.merge = function (array, cmp, start, middle, end) {
|
50 | 60 | var left = [];
|
|
0 commit comments