Hoogle Search

Within LTS Haskell 24.4 (ghc-9.10.2)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. sortBy :: ListLike full item => (item -> item -> Ordering) -> full -> full

    ListLike Data.ListLike.Base

    Sort function taking a custom comparison function

  2. sortBy :: (a -> a -> Ordering) -> [a] -> [a]

    basic-prelude BasicPrelude

    The sortBy function is the non-overloaded version of sort. The argument must be finite. The supplied comparison relation is supposed to be reflexive and antisymmetric, otherwise, e. g., for _ _ -> GT, the ordered list simply does not exist. The relation is also expected to be transitive: if it is not then sortBy might fail to find an ordered permutation, even if it exists.

    Examples

    >>> sortBy (\(a,_) (b,_) -> compare a b) [(2, "world"), (4, "!"), (1, "Hello")]
    [(1,"Hello"),(2,"world"),(4,"!")]
    

  3. sortOn :: Ord b => (a -> b) -> [a] -> [a]

    basic-prelude BasicPrelude

    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)]
    

  4. sortWith :: (Ord a, IsSequence c) => (Element c -> a) -> c -> c

    classy-prelude ClassyPrelude

    Sort elements using the user supplied function to project something out of each element. Inspired by http://hackage.haskell.org/packages/archive/base/latest/doc/html/GHC-Exts.html#v:sortWith.

  5. sortQuantVars :: [Var] -> [Var]

    ghc-lib-parser GHC.Core.Make

    Sort the variables, putting type and covars first, in scoped order, and then other Ids It is a deterministic sort, meaning it doesn't look at the values of Uniques. For explanation why it's important See Note [Unique Determinism] in GHC.Types.Unique.

  6. sORTKind_maybe :: Kind -> Maybe (TypeOrConstraint, Type)

    ghc-lib-parser GHC.Core.Type

    No documentation available.

  7. sortLocatedA :: HasLoc (EpAnn a) => [GenLocated (EpAnn a) e] -> [GenLocated (EpAnn a) e]

    ghc-lib-parser GHC.Parser.Annotation

    No documentation available.

  8. sortAvails :: Avails -> DetOrdAvails

    ghc-lib-parser GHC.Types.Avail

    Sort Avails/AvailInfos

  9. sortLocated :: [Located a] -> [Located a]

    ghc-lib-parser GHC.Types.SrcLoc

    No documentation available.

  10. sortRealLocated :: [RealLocated a] -> [RealLocated a]

    ghc-lib-parser GHC.Types.SrcLoc

    No documentation available.

Page 27 of many | Previous | Next