@@ -11,6 +11,12 @@ package sort
11
11
// A type, typically a collection, that satisfies sort.Interface can be
12
12
// sorted by the routines in this package. The methods require that the
13
13
// elements of the collection be enumerated by an integer index.
14
+ //
15
+ // The sort routines require that the Less method implements a strict weak
16
+ // ordering; see https://en.wikipedia.org/wiki/Weak_ordering.
17
+ // The < operations on ints and strings are examples of such an ordering,
18
+ // whereas the < operation on floating-point numbers is not, due to the
19
+ // behavior of not-a-number (NaN) values.
14
20
type Interface interface {
15
21
// Len is the number of elements in the collection.
16
22
Len () int
@@ -275,8 +281,9 @@ func (p IntSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
275
281
// Sort is a convenience method.
276
282
func (p IntSlice ) Sort () { Sort (p ) }
277
283
278
- // Float64Slice attaches the methods of Interface to []float64, sorting in increasing order
279
- // (not-a-number values are treated as less than other values).
284
+ // Float64Slice attaches the methods of Interface to []float64, sorting in increasing order.
285
+ // In order to satisfy the ordering requirements of the Less method, not-a-number (NaN)
286
+ // values are treated as less than other values.
280
287
type Float64Slice []float64
281
288
282
289
func (p Float64Slice ) Len () int { return len (p ) }
0 commit comments