@@ -76,15 +76,17 @@ import Data.Sequence.Internal
76
76
foldWithIndexNode )
77
77
import Utils.Containers.Internal.State (State (.. ), execState )
78
78
-- | \( O(n \log n) \). 'sort' sorts the specified 'Seq' by the natural
79
- -- ordering of its elements. The sort is stable. If stability is not
79
+ -- ordering of its elements. The sort is stable, meaning the order of equal
80
+ -- elements is preserved. If stability is not
80
81
-- required, 'unstableSort' can be slightly faster.
81
82
--
82
83
-- @since 0.3.0
83
84
sort :: Ord a => Seq a -> Seq a
84
85
sort = sortBy compare
85
86
86
87
-- | \( O(n \log n) \). 'sortBy' sorts the specified 'Seq' according to the
87
- -- specified comparator. The sort is stable. If stability is not required,
88
+ -- specified comparator. The sort is stable, meaning the order of equal
89
+ -- elements is preserved. If stability is not required,
88
90
-- 'unstableSortBy' can be slightly faster.
89
91
--
90
92
-- @since 0.3.0
@@ -96,11 +98,11 @@ sortBy cmp (Seq xs) =
96
98
(buildIQ cmp (\ s (Elem x) -> IQ s x IQNil ) 0 xs)
97
99
98
100
-- | \( O(n \log n) \). 'sortOn' sorts the specified 'Seq' by comparing
99
- -- the results of a key function applied to each element. @'sortOn' f@ is
101
+ -- the results of a key function applied to each element. The sort is stable,
102
+ -- meaning the order of equal elements is preserved. @'sortOn' f@ is
100
103
-- equivalent to @'sortBy' ('compare' ``Data.Function.on`` f)@, but has the
101
104
-- performance advantage of only evaluating @f@ once for each element in the
102
- -- input list. This is called the decorate-sort-undecorate paradigm, or
103
- -- Schwartzian transform.
105
+ -- input 'Seq'.
104
106
--
105
107
-- An example of using 'sortOn' might be to sort a 'Seq' of strings
106
108
-- according to their length:
@@ -151,8 +153,7 @@ unstableSortBy cmp (Seq xs) =
151
153
-- comparing the results of a key function applied to each element.
152
154
-- @'unstableSortOn' f@ is equivalent to @'unstableSortBy' ('compare' ``Data.Function.on`` f)@,
153
155
-- but has the performance advantage of only evaluating @f@ once for each
154
- -- element in the input list. This is called the
155
- -- decorate-sort-undecorate paradigm, or Schwartzian transform.
156
+ -- element in the input 'Seq'.
156
157
--
157
158
-- An example of using 'unstableSortOn' might be to sort a 'Seq' of strings
158
159
-- according to their length:
0 commit comments