In haskell I can use
sortBy (comparing snd)
to sort by the second value in a tuple.
Is there an equivalent function for testing equivalency? I've come up with this but maybe there is something in the standard library.
equalsBy :: Eq b => (a -> b) -> a -> a -> Bool
equalsBy f x y = f x == f y
The end goal is to group a list of pairs by their second values. With this I can do
groupBy (equalsBy snd) pairs
instead of
groupBy (\x y -> (snd x) == (snd y)) pairs