@@ -78,12 +78,16 @@ import Utils.Containers.Internal.State (State(..), execState)
78
78
-- | \( O(n \log n) \). 'sort' sorts the specified 'Seq' by the natural
79
79
-- ordering of its elements. The sort is stable. If stability is not
80
80
-- required, 'unstableSort' can be slightly faster.
81
+ --
82
+ -- @since 0.3.0
81
83
sort :: Ord a => Seq a -> Seq a
82
84
sort = sortBy compare
83
85
84
86
-- | \( O(n \log n) \). 'sortBy' sorts the specified 'Seq' according to the
85
87
-- specified comparator. The sort is stable. If stability is not required,
86
88
-- 'unstableSortBy' can be slightly faster.
89
+ --
90
+ -- @since 0.3.0
87
91
sortBy :: (a -> a -> Ordering ) -> Seq a -> Seq a
88
92
sortBy cmp (Seq xs) =
89
93
maybe
@@ -110,6 +114,8 @@ sortBy cmp (Seq xs) =
110
114
-- If @f@ is very cheap (for example a record selector, or 'fst'),
111
115
-- @'sortBy' ('compare' ``Data.Function.on`` f)@ will be faster than
112
116
-- @'sortOn' f@.
117
+ --
118
+ -- @since 0.5.11
113
119
sortOn :: Ord b => (a -> b ) -> Seq a -> Seq a
114
120
sortOn f (Seq xs) =
115
121
maybe
@@ -123,13 +129,17 @@ sortOn f (Seq xs) =
123
129
124
130
-- Notes on the implementation and choice of heap are available in
125
131
-- the file sorting.md (in this directory).
132
+ --
133
+ -- @since 0.3.0
126
134
unstableSort :: Ord a => Seq a -> Seq a
127
135
unstableSort = unstableSortBy compare
128
136
129
137
-- | \( O(n \log n) \). A generalization of 'unstableSort', 'unstableSortBy'
130
138
-- takes an arbitrary comparator and sorts the specified sequence.
131
139
-- The sort is not stable. This algorithm is frequently faster and
132
140
-- uses less memory than 'sortBy'.
141
+ --
142
+ -- @since 0.3.0
133
143
unstableSortBy :: (a -> a -> Ordering ) -> Seq a -> Seq a
134
144
unstableSortBy cmp (Seq xs) =
135
145
maybe
@@ -156,6 +166,8 @@ unstableSortBy cmp (Seq xs) =
156
166
-- If @f@ is very cheap (for example a record selector, or 'fst'),
157
167
-- @'unstableSortBy' ('compare' ``Data.Function.on`` f)@ will be faster than
158
168
-- @'unstableSortOn' f@.
169
+ --
170
+ -- @since 0.5.11
159
171
unstableSortOn :: Ord b => (a -> b ) -> Seq a -> Seq a
160
172
unstableSortOn f (Seq xs) =
161
173
maybe
0 commit comments