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

10 lines
256 B
Haskell
Raw Normal View History

import Data.List (sortBy)
2024-05-25 19:28:16 -05:00
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