Haskell by Example: Sorting by Functions

original
import Data.List
import Data.Function

main = do
    let fruits = ["peach", "banana", "kiwi"]
    print $ sortBy (compare `on` length) fruits
$ runhaskell sorting-by-functions.hs
["kiwi","peach","banana"]
back to index