Skip to content

Commit d2b3ee3

Browse files
committed
Add Array.sortInPlace for List.sort
1 parent 4d086ce commit d2b3ee3

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

src/Core__List.mjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import * as Curry from "rescript/lib/es6/curry.js";
44
import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
55
import * as Caml_option from "rescript/lib/es6/caml_option.js";
66
import * as Core__Array from "./Core__Array.mjs";
7-
import * as Belt_SortArray from "rescript/lib/es6/belt_SortArray.js";
87

98
function head(x) {
109
if (x) {
@@ -1177,9 +1176,8 @@ function setAssoc(xs, x, k, eq) {
11771176
}
11781177

11791178
function sort(xs, cmp) {
1180-
var cmp$1 = Curry.__2(cmp);
11811179
var arr = toArray(xs);
1182-
Belt_SortArray.stableSortInPlaceByU(arr, cmp$1);
1180+
arr.sort(cmp);
11831181
return fromArray(arr);
11841182
}
11851183

src/Core__List.res

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -793,14 +793,12 @@ let setAssocU = (xs, x, k, eq) =>
793793

794794
let setAssoc = (xs, x, k, eq) => setAssocU(xs, x, k, (. a, b) => eq(a, b))
795795

796-
let sortU = (xs, cmp) => {
796+
let sort = (xs, cmp) => {
797797
let arr = toArray(xs)
798-
Belt_SortArray.stableSortInPlaceByU(arr, cmp)
798+
Core__Array.sortInPlace(arr, cmp)
799799
fromArray(arr)
800800
}
801801

802-
let sort = (xs, cmp) => sortU(xs, (. x, y) => cmp(x, y))
803-
804802
let rec getByU = (xs, p) =>
805803
switch xs {
806804
| list{} => None

0 commit comments

Comments
 (0)