Sort using a custom comparator: Difference between revisions
→{{header|Haskell}}: (slight rearrangement of monoid example)
(→{{header|Haskell}}: Further simplification, using `comparing` in lieu of `compare on`, and infix <> in lieu of mappend) |
(→{{header|Haskell}}: (slight rearrangement of monoid example)) |
||
Line 1,080:
-- EQ `mappend` y = y
-- GT `mappend` _ = GT
mycmpUp = comparing length <> comparing (toLower <$>)▼
mycmpDown = flip (comparing length) <> comparing (toLower <$>)▼
xs :: [String]
Line 1,091 ⟶ 1,085:
main :: IO ()
main =
mapM_ putStrLn $
(unlines . flip sortBy xs) <$>
]</lang>
{{Out}}
|