Skip to content

Commit

Permalink
Make Array.prototype.sort stable
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRosenwasser authored and gbrail committed Jul 17, 2024
1 parent 5bdd291 commit caff4d9
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 327 deletions.
3 changes: 2 additions & 1 deletion rhino/src/main/java/org/mozilla/javascript/NativeArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,8 @@ public int compare(final Object x, final Object y) {
working[i] = getRawElem(o, i);
}

Sorting.get().hybridSort(working, comparator);
// 'Arrays.sort' is guaranteed to be stable.
Arrays.sort(working, comparator);

// copy the working array back into thisObj
for (int i = 0; i < length; ++i) {
Expand Down
129 changes: 0 additions & 129 deletions rhino/src/main/java/org/mozilla/javascript/Sorting.java

This file was deleted.

195 changes: 0 additions & 195 deletions rhino/src/test/java/org/mozilla/javascript/tests/SortingTest.java

This file was deleted.

2 changes: 0 additions & 2 deletions tests/testsrc/test262.properties
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ built-ins/Array 146/2670 (5.47%)
prototype/slice/target-array-with-non-configurable-property.js
prototype/some/15.4.4.17-5-1-s.js non-strict
prototype/sort/S15.4.4.11_A8.js non-strict
prototype/sort/stability-2048-elements.js
prototype/sort/stability-513-elements.js
prototype/splice/clamps-length-to-integer-limit.js
prototype/splice/create-ctor-non-object.js
prototype/splice/create-ctor-poisoned.js
Expand Down

0 comments on commit caff4d9

Please # to comment.