module HAD.Y2014.M03.D03.Exercise where

import Data.List
import Data.Function
-- | Sort a list of list of elements by the maximum of each list,
-- in ascending order
-- 
-- Point-free: easy and readable
-- Level: EASY
--
-- Examples:
-- >>> sortByMax [[1,10],[5,5]]
-- [[5,5],[1,10]]
-- >>> sortByMax []
-- []
-- 
-- sortByMax [[], [1,2]]
-- should throw an execption: no max for empty list

sortByMax :: Ord a => [[a]] -> [[a]]
sortByMax = sortBy (compare `on` maximum)
