Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update doc comments for sorting #1006

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions containers/src/Data/Sequence/Internal/Sorting.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,17 @@ import Data.Sequence.Internal
foldWithIndexNode)
import Utils.Containers.Internal.State (State(..), execState)
-- | \( O(n \log n) \). 'sort' sorts the specified 'Seq' by the natural
-- ordering of its elements. The sort is stable. If stability is not
-- ordering of its elements. The sort is stable, meaning the order of equal
-- elements is preserved. If stability is not
-- required, 'unstableSort' can be slightly faster.
--
-- @since 0.3.0
sort :: Ord a => Seq a -> Seq a
sort = sortBy compare

-- | \( O(n \log n) \). 'sortBy' sorts the specified 'Seq' according to the
-- specified comparator. The sort is stable. If stability is not required,
-- specified comparator. The sort is stable, meaning the order of equal
-- elements is preserved. If stability is not required,
-- 'unstableSortBy' can be slightly faster.
--
-- @since 0.3.0
Expand All @@ -96,11 +98,11 @@ sortBy cmp (Seq xs) =
(buildIQ cmp (\s (Elem x) -> IQ s x IQNil) 0 xs)

-- | \( O(n \log n) \). 'sortOn' sorts the specified 'Seq' by comparing
-- the results of a key function applied to each element. @'sortOn' f@ is
-- the results of a key function applied to each element. The sort is stable,
-- meaning the order of equal elements is preserved. @'sortOn' f@ is
-- equivalent to @'sortBy' ('compare' ``Data.Function.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.
-- input 'Seq'.
--
-- An example of using 'sortOn' might be to sort a 'Seq' of strings
-- according to their length:
Expand Down Expand Up @@ -151,8 +153,7 @@ unstableSortBy cmp (Seq xs) =
-- comparing the results of a key function applied to each element.
-- @'unstableSortOn' f@ is equivalent to @'unstableSortBy' ('compare' ``Data.Function.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.
-- element in the input 'Seq'.
--
-- An example of using 'unstableSortOn' might be to sort a 'Seq' of strings
-- according to their length:
Expand Down
Loading