File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 73
73
74
74
sort :: forall a. (Ord a) => [a] -> [a]
75
75
76
+ sortBy :: forall a. (a -> a -> Ordering) -> [a] -> [a]
77
+
76
78
tail :: forall a. [a] -> Maybe [a]
77
79
78
80
take :: forall a. Prim.Number -> [a] -> [a]
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ module Data.Array
29
29
, nub
30
30
, nubBy
31
31
, sort
32
+ , sortBy
32
33
) where
33
34
34
35
import Data.Maybe
@@ -263,12 +264,15 @@ nubBy _ [] = []
263
264
nubBy (==) (x:xs) = x : nubBy (==) (filter (\y -> not (x == y)) xs)
264
265
265
266
sort :: forall a . (Ord a ) => [a ] -> [a ]
266
- sort xs = sortJS comp xs
267
+ sort xs = sortBy compare xs
268
+
269
+ sortBy :: forall a . (a -> a -> Ordering ) -> [a ] -> [a ]
270
+ sortBy comp xs = sortJS comp' xs
267
271
where
268
- comp x y = case compare x y of
269
- GT -> 1
270
- EQ -> 0
271
- LT -> -1
272
+ comp' x y = case comp x y of
273
+ GT -> 1
274
+ EQ -> 0
275
+ LT -> -1
272
276
273
277
foreign import sortJS
274
278
" function sortJS (f) {\
You can’t perform that action at this time.
0 commit comments