|
7 | 7 | // Package sort provides primitives for sorting slices and user-defined collections.
|
8 | 8 | package sort
|
9 | 9 |
|
10 |
| -import "math/bits" |
| 10 | +import ( |
| 11 | + "math/bits" |
| 12 | + "slices" |
| 13 | +) |
11 | 14 |
|
12 | 15 | // An implementation of Interface can be sorted by the routines in this package.
|
13 | 16 | // The methods refer to elements of the underlying collection by integer index.
|
@@ -162,34 +165,34 @@ func (x StringSlice) Sort() { Sort(x) }
|
162 | 165 | // Ints sorts a slice of ints in increasing order.
|
163 | 166 | //
|
164 | 167 | // Note: as of Go 1.22, this function simply calls [slices.Sort].
|
165 |
| -func Ints(x []int) { intsImpl(x) } |
| 168 | +func Ints(x []int) { slices.Sort(x) } |
166 | 169 |
|
167 | 170 | // Float64s sorts a slice of float64s in increasing order.
|
168 | 171 | // Not-a-number (NaN) values are ordered before other values.
|
169 | 172 | //
|
170 | 173 | // Note: as of Go 1.22, this function simply calls [slices.Sort].
|
171 |
| -func Float64s(x []float64) { float64sImpl(x) } |
| 174 | +func Float64s(x []float64) { slices.Sort(x) } |
172 | 175 |
|
173 | 176 | // Strings sorts a slice of strings in increasing order.
|
174 | 177 | //
|
175 | 178 | // Note: as of Go 1.22, this function simply calls [slices.Sort].
|
176 |
| -func Strings(x []string) { stringsImpl(x) } |
| 179 | +func Strings(x []string) { slices.Sort(x) } |
177 | 180 |
|
178 | 181 | // IntsAreSorted reports whether the slice x is sorted in increasing order.
|
179 | 182 | //
|
180 | 183 | // Note: as of Go 1.22, this function simply calls [slices.IsSorted].
|
181 |
| -func IntsAreSorted(x []int) bool { return intsAreSortedImpl(x) } |
| 184 | +func IntsAreSorted(x []int) bool { return slices.IsSorted(x) } |
182 | 185 |
|
183 | 186 | // Float64sAreSorted reports whether the slice x is sorted in increasing order,
|
184 | 187 | // with not-a-number (NaN) values before any other values.
|
185 | 188 | //
|
186 | 189 | // Note: as of Go 1.22, this function simply calls [slices.IsSorted].
|
187 |
| -func Float64sAreSorted(x []float64) bool { return float64sAreSortedImpl(x) } |
| 190 | +func Float64sAreSorted(x []float64) bool { return slices.IsSorted(x) } |
188 | 191 |
|
189 | 192 | // StringsAreSorted reports whether the slice x is sorted in increasing order.
|
190 | 193 | //
|
191 | 194 | // Note: as of Go 1.22, this function simply calls [slices.IsSorted].
|
192 |
| -func StringsAreSorted(x []string) bool { return stringsAreSortedImpl(x) } |
| 195 | +func StringsAreSorted(x []string) bool { return slices.IsSorted(x) } |
193 | 196 |
|
194 | 197 | // Notes on stable sorting:
|
195 | 198 | // The used algorithms are simple and provable correct on all input and use
|
|
0 commit comments