Hoogle Search
Within LTS Haskell 24.5 (ghc-9.10.2)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
sortV :: Ord a => Vector a -> Vector aharpie Harpie.Sort return the sorted array
>>> sortV (V.fromList [3,1,4,2,0,5::Int]) [0,1,2,3,4,5]
sortBy :: (a -> a -> Ordering) -> NESeq a -> NESeq anonempty-containers Data.Sequence.NonEmpty sortBy sorts the specified NESeq according to the specified comparator. The sort is stable. If stability is not required, unstableSortBy can be slightly faster.
sortOn :: Ord b => (a -> b) -> NESeq a -> NESeq anonempty-containers Data.Sequence.NonEmpty sortOn sorts the specified NESeq by comparing the results of a key function applied to each element. sortOn f is equivalent to sortBy (compare `on` 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. An example of using sortOn might be to sort a NESeq of strings according to their length:
sortOn length (fromList ("alligator" :| ["monkey", "zebra"])) == fromList ("zebra" :| ["monkey", "alligator"])
If, instead, sortBy had been used, length would be evaluated on every comparison, giving <math> evaluations, rather than <math>. If f is very cheap (for example a record selector, or fst), sortBy (compare `on` f) will be faster than sortOn f.sortBy :: (a -> a -> Ordering) -> [a] -> [a]prelude-compat Data.List2010 No documentation available.
sortWith :: Ord b => (a -> b) -> [a] -> [a]rebase Rebase.Prelude The sortWith function sorts a list of elements using the user supplied function to project something out of each element In general if the user supplied function is expensive to compute then you should probably be using sortOn, as it only needs to compute it once for each element. sortWith, on the other hand must compute the mapping function for every comparison that it performs.
sortBy :: (Functor io, MonadIO io) => (a -> a -> Ordering) -> Shell a -> io [a]turtle Turtle.Prelude Return a list of the elements of the given Shell, sorted by the given function and keeping duplicates:
>>> sortBy (comparing fst) (select [(1,'a'),(4,'b'),(2,'c'),(3,'d'),(3,'e'),(7,'f')]) [(1,'a'),(2,'c'),(3,'d'),(3,'e'),(4,'b'),(7,'f')]
sortOn :: (Functor io, MonadIO io, Ord b) => (a -> b) -> Shell a -> io [a]turtle Turtle.Prelude Return a list of the elements of the given Shell, sorted after applying the given function and keeping duplicates:
>>> sortOn id (select [1,4,2,3,3,7]) [1,2,3,3,4,7]
sortKey :: Collator -> Text -> SortKeyunicode-collation Text.Collate The sort key used to compare a Text
sortWith :: Ord b => (a -> b) -> [a] -> [a]base-prelude BasePrelude The sortWith function sorts a list of elements using the user supplied function to project something out of each element In general if the user supplied function is expensive to compute then you should probably be using sortOn, as it only needs to compute it once for each element. sortWith, on the other hand must compute the mapping function for every comparison that it performs.
sortBy :: (a -> a -> Ordering) -> [a] -> [a]data-ordlist Data.List.Ordered 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,"!")]