Skip to content

Commit 110819e

Browse files
committed
add docs for StableSort & StableSort.inplace
1 parent d860725 commit 110819e

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

src/utils/array/StableSort.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,33 @@
99

1010
(function() {
1111

12-
// A stable array sort, because `Array#sort()` is not guaranteed stable.
13-
// This is an implementation of merge sort, without recursion.
14-
12+
/**
13+
* A stable array sort, because `Array#sort()` is not guaranteed stable.
14+
* This is an implementation of merge sort, without recursion.
15+
*
16+
* @function Phaser.Utils.Array.StableSort
17+
* @since 3.0.0
18+
*
19+
* @param {array} arr - The input array to be sorted.
20+
* @param {function} comp - The comparison handler.
21+
*
22+
* @return {array} The sorted result.
23+
*/
1524
var stable = function(arr, comp) {
1625
return exec(arr.slice(), comp);
1726
};
1827

28+
/**
29+
* Sort the input array and simply copy it back if the result isn't in the original array, which happens on an odd number of passes.
30+
*
31+
* @function Phaser.Utils.Array.StableSort.inplace
32+
* @since 3.0.0
33+
*
34+
* @param {array} arr - The input array.
35+
* @param {function} comp - The comparison handler.
36+
*
37+
* @return {array} The sorted array.
38+
*/
1939
stable.inplace = function(arr, comp) {
2040
var result = exec(arr, comp);
2141

0 commit comments

Comments
 (0)