Update: This function is now available in the Data.Ord module under the name comparing.
Data.Ord
comparing
compareBy :: Ord b => (a -> b) -> a -> a -> Ordering compareBy f x y = f x `compare` f y
sortBy (compareBy length) ["abc", "a", "ab"] ↪ ["a","ab","abc"]