summaryrefslogtreecommitdiff
path: root/src/sort
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2017-05-31 13:43:52 -0700
committerIan Lance Taylor <iant@golang.org>2017-05-31 20:50:34 +0000
commit4c96ff4444f2393e924e826ac6b6b6459d3db9d6 (patch)
treef0a4e6a8a077a80a6c5431e62acf832ea7e555bb /src/sort
parent1e0819101b476f807bf8ef3fd50f1ee26691f33e (diff)
downloadgo-git-4c96ff4444f2393e924e826ac6b6b6459d3db9d6.tar.gz
sort: document NaN behavior for Float64Slice and friends
Fixes #20540 Change-Id: I440eee02d37b6921613f9ae77875d91eeec48b1e Reviewed-on: https://go-review.googlesource.com/44490 Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/sort')
-rw-r--r--src/sort/sort.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/sort/sort.go b/src/sort/sort.go
index 54f92a4217..abb574bacd 100644
--- a/src/sort/sort.go
+++ b/src/sort/sort.go
@@ -314,7 +314,8 @@ func (p IntSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
// Sort is a convenience method.
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
func (p Float64Slice) Len() int { return len(p) }
@@ -344,7 +345,8 @@ func (p StringSlice) Sort() { Sort(p) }
// Ints sorts a slice of ints in increasing order.
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)) }
// Strings sorts a slice of strings in increasing order.
@@ -353,7 +355,8 @@ func Strings(a []string) { Sort(StringSlice(a)) }
// IntsAreSorted tests whether a slice of ints is sorted in increasing order.
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)) }
// StringsAreSorted tests whether a slice of strings is sorted in increasing order.