Commit 4c96ff44 authored by Ian Lance Taylor's avatar Ian Lance Taylor

sort: document NaN behavior for Float64Slice and friends

Fixes #20540

Change-Id: I440eee02d37b6921613f9ae77875d91eeec48b1e
Reviewed-on: https://go-review.googlesource.com/44490Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
parent 1e081910
...@@ -314,7 +314,8 @@ func (p IntSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } ...@@ -314,7 +314,8 @@ func (p IntSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
// Sort is a convenience method. // Sort is a convenience method.
func (p IntSlice) Sort() { Sort(p) } func (p IntSlice) Sort() { Sort(p) }
// Float64Slice attaches the methods of Interface to []float64, sorting in increasing order. // Float64Slice attaches the methods of Interface to []float64, sorting in increasing order
// (not-a-number values are treated as less than any ordinary number).
type Float64Slice []float64 type Float64Slice []float64
func (p Float64Slice) Len() int { return len(p) } func (p Float64Slice) Len() int { return len(p) }
...@@ -344,7 +345,8 @@ func (p StringSlice) Sort() { Sort(p) } ...@@ -344,7 +345,8 @@ func (p StringSlice) Sort() { Sort(p) }
// Ints sorts a slice of ints in increasing order. // Ints sorts a slice of ints in increasing order.
func Ints(a []int) { Sort(IntSlice(a)) } func Ints(a []int) { Sort(IntSlice(a)) }
// Float64s sorts a slice of float64s in increasing order. // Float64s sorts a slice of float64s in increasing order
// (not-a-number values are treated as less than any ordinary number).
func Float64s(a []float64) { Sort(Float64Slice(a)) } func Float64s(a []float64) { Sort(Float64Slice(a)) }
// Strings sorts a slice of strings in increasing order. // Strings sorts a slice of strings in increasing order.
...@@ -353,7 +355,8 @@ func Strings(a []string) { Sort(StringSlice(a)) } ...@@ -353,7 +355,8 @@ func Strings(a []string) { Sort(StringSlice(a)) }
// IntsAreSorted tests whether a slice of ints is sorted in increasing order. // IntsAreSorted tests whether a slice of ints is sorted in increasing order.
func IntsAreSorted(a []int) bool { return IsSorted(IntSlice(a)) } func IntsAreSorted(a []int) bool { return IsSorted(IntSlice(a)) }
// Float64sAreSorted tests whether a slice of float64s is sorted in increasing order. // Float64sAreSorted tests whether a slice of float64s is sorted in increasing order
// (not-a-number values are treated as less than any ordinary number).
func Float64sAreSorted(a []float64) bool { return IsSorted(Float64Slice(a)) } func Float64sAreSorted(a []float64) bool { return IsSorted(Float64Slice(a)) }
// StringsAreSorted tests whether a slice of strings is sorted in increasing order. // StringsAreSorted tests whether a slice of strings is sorted in increasing order.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment