[Haskell-beginners] List.sort

Patrick LeBoutillier patrick.leboutillier at gmail.com
Sat Jul 11 09:06:21 EDT 2009


Hi,

I see the type of the List.sort function is:

  Ord a => [a] -> [a]

I don't understand how this type can allow it to sort pairs:

Prelude> :m +List
Prelude List> sort [(1, "1"), (3, "3"), (2, "2")]
[(1,"1"),(2,"2"),(3,"3")]

How can a pair by of type "Ord a"? Is it a rule that the first element
is automatically used?


Patrick

-- 
=====================
Patrick LeBoutillier
Rosemère, Québec, Canada


More information about the Beginners mailing list