-- | Orderings

module Data.Ord where

-- |
-- > comparing p x y = compare (p x) (p y)
--
-- Useful combinator for use in conjunction with the @xxxBy@ family
-- of functions from "Data.List", for example:
--
-- >   ... sortBy (comparing fst) ...
comparing :: (Ord a) => (b -> a) -> b -> b -> Ordering
comparing :: (b -> a) -> b -> b -> Ordering
comparing b -> a
p b
x b
y = a -> a -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (b -> a
p b
x) (b -> a
p b
y)