2 "This tests that sort(compareFn) is a stable sort."
5 function clone(source
, target
) {
6 for (i
= 0; i
< source
.length
; i
++) {
12 arr
[0] = new Number(1);
13 arr
[1] = new Number(2);
14 arr
[2] = new Number(1);
15 arr
[3] = new Number(2);
19 sortArr
.sort(function(a
,b
) { return a
- b
; });
21 shouldBe('arr[0]', 'sortArr[0]');
22 shouldBe('arr[1]', 'sortArr[2]');
23 shouldBe('arr[2]', 'sortArr[1]');
24 shouldBe('arr[3]', 'sortArr[3]');
27 sortArr
.sort(function(a
,b
) { return a
- b
; });
28 shouldBe('arr[0]', 'sortArr[0]');
29 shouldBe('arr[1]', 'sortArr[2]');
30 shouldBe('arr[2]', 'sortArr[1]');
31 shouldBe('arr[3]', 'sortArr[3]');