MCPcopy Index your code
hub / github.com/phaserjs/phaser / Process

Function Process

src/utils/array/StableSort.js:35–62  ·  view source on GitHub ↗

* Process the array contents. * * @ignore * * @param {array} array - The array to process. * @param {function} compare - The comparison function. * * @return {array} - The processed array.

(array, compare)

Source from the content-addressed store, hash-verified

33 * @return {array} - The processed array.
34 */
35function Process (array, compare)
36{
37 // Short-circuit when there's nothing to sort.
38 var len = array.length;
39
40 if (len <= 1)
41 {
42 return array;
43 }
44
45 // Rather than dividing input, simply iterate chunks of 1, 2, 4, 8, etc.
46 // Chunks are the size of the left or right hand in merge sort.
47 // Stop when the left-hand covers all of the array.
48 var buffer = new Array(len);
49
50 for (var chk = 1; chk < len; chk *= 2)
51 {
52 RunPass(array, compare, chk, buffer);
53
54 var tmp = array;
55
56 array = buffer;
57
58 buffer = tmp;
59 }
60
61 return array;
62}
63
64/**
65 * Run a single pass with the given chunk size.

Callers 1

StableSortFunction · 0.85

Calls 1

RunPassFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…