-- Reads a set of strings separated by newlines from stdin, sorts them -- by length in descending order, writes them to stdout. import Data.List listItemsToTuplesWithLength :: [String] -> [(Int, String)] listItemsToTuplesWithLength = map (\x -> (length x, x)) main :: IO () main = do input <- getContents mapM_ (putStrLn . snd) (sortBy (flip compare) (listItemsToTuplesWithLength $ lines input))