99-haskell-problems/Problems 21-28/problem_28.hs

9 lines
256 B
Haskell

import Data.List (sortBy)
lsort :: [[a]] -> [[a]]
lsort = sortBy (\x y -> length x `compare` length y)
lfsort :: [[a]] -> [[a]]
lfsort ls = sortBy (\x y -> count x `compare` count y) ls
where
count x = length . filter (length x ==) $ map length ls