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 7373
7474 sort :: forall a. (Ord a) => [a] -> [a]
7575
76+ sortBy :: forall a. (a -> a -> Ordering) -> [a] -> [a]
77+
7678 tail :: forall a. [a] -> Maybe [a]
7779
7880 take :: forall a. Prim.Number -> [a] -> [a]
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ module Data.Array
2929 , nub
3030 , nubBy
3131 , sort
32+ , sortBy
3233 ) where
3334
3435import Data.Maybe
@@ -263,12 +264,15 @@ nubBy _ [] = []
263264nubBy (==) (x:xs) = x : nubBy (==) (filter (\y -> not (x == y)) xs)
264265
265266sort :: 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
267271 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
272276
273277foreign import sortJS
274278 " function sortJS (f) {\
You can’t perform that action at this time.
0 commit comments