Advertisement
banovski

Reverse length string sorter

Oct 4th, 2023 (edited)
1,789
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haskell 0.29 KB | Source Code | 0 0
  1. -- Reads a set of strings separated by newlines from stdin, sorts them
  2. -- by length in descending order, writes them to stdout.
  3.  
  4. import Data.List
  5. import Data.Function
  6.  
  7. main :: IO ()
  8. main = do
  9.   input <- getContents
  10.   mapM_ putStrLn $ sortBy (flip (on compare length)) (lines input)
  11.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement