Let's say we have a custom data type:
data Person = Person { first_name :: String,
last_name :: String,
age :: Int
} deriving (Ord, Eq, Show)
Let's also say I have a list of these Person data types. I've already made a function that sorts these Persons in order, but this is limited to the first value of each person, first_name. What I'm trying to do is modify the Person data type so that this sort function sorts by the age instead of first_name (besides just swapping the value order so that age is first). I know I need to use the instance keyword to write my own compare function for Ord. This is where I'm stuck. Can anyone help me out?
Edit: Yep, this is HW-- I unfortunately need to do it the way I'm describing.