Hoogle Search
Within LTS Haskell 24.6 (ghc-9.10.2)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
sortOn :: Ord b => (a -> b) -> [a] -> [a]rio RIO.List Sort a list by comparing the results of a key function applied to each element. sortOn f is equivalent to sortBy (comparing f), but has the performance advantage of only evaluating f once for each element in the input list. This is called the decorate-sort-undecorate paradigm, or Schwartzian transform. Elements are arranged from lowest to highest, keeping duplicates in the order they appeared in the input. The argument must be finite.
Examples
>>> sortOn fst [(2, "world"), (4, "!"), (1, "Hello")] [(1,"Hello"),(2,"world"),(4,"!")]
>>> sortOn length ["jim", "creed", "pam", "michael", "dwight", "kevin"] ["jim","pam","creed","kevin","dwight","michael"]
Performance notes
This function minimises the projections performed, by materialising the projections in an intermediate list. For trivial projections, you should prefer using sortBy with comparing, for example:>>> sortBy (comparing fst) [(3, 1), (2, 2), (1, 3)] [(1,3),(2,2),(3,1)]
Or, for the exact same API as sortOn, you can use `sortBy . comparing`:>>> (sortBy . comparing) fst [(3, 1), (2, 2), (1, 3)] [(1,3),(2,2),(3,1)]
sortBy :: (a -> a -> Ordering) -> NonEmpty a -> NonEmpty ario RIO.NonEmpty sortWith :: Ord o => (a -> o) -> NonEmpty a -> NonEmpty ario RIO.NonEmpty sortWith for NonEmpty, behaves the same as:
sortBy . comparing
sortBy :: (a -> a -> Ordering) -> Seq a -> Seq ario RIO.Seq sortBy sorts the specified Seq according to the specified comparator. The sort is stable. If stability is not required, unstableSortBy can be slightly faster.
sortBy :: Vector v e => Comparison e -> v e -> v estatistics Statistics.Function Sort a vector using a custom ordering.
-
HsOpenSSL OpenSSL.X509.Revocation sortCRL crl sorts the certificates in the revocation list.
sortedConvexHull :: OrderedField n => [P2 n] -> ([P2 n], [P2 n])diagrams-lib Diagrams.TwoD.Points Find the convex hull of a set of points already sorted in the x direction. The first list of the tuple is the upper hull going clockwise from left-most to right-most point. The second is the lower hull from right-most to left-most in the anti-clockwise direction.
sortBy :: (a -> a -> Ordering) -> [a] -> [a]Cabal-syntax Distribution.Compat.Prelude No documentation available.
-
hedis Database.Redis No documentation available.
sortBy :: SortOpts -> Maybe ByteStringhedis Database.Redis No documentation available.