diff options
Diffstat (limited to 'src/pkg/sort/sort.go')
-rw-r--r-- | src/pkg/sort/sort.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/pkg/sort/sort.go b/src/pkg/sort/sort.go index e10961992..d3092e801 100644 --- a/src/pkg/sort/sort.go +++ b/src/pkg/sort/sort.go @@ -6,8 +6,6 @@ // collections. package sort -import "math" - // A type, typically a collection, that satisfies sort.Interface can be // sorted by the routines in this package. The methods require that the // elements of the collection be enumerated by an integer index. @@ -245,9 +243,14 @@ func (p IntSlice) Sort() { Sort(p) } type Float64Slice []float64 func (p Float64Slice) Len() int { return len(p) } -func (p Float64Slice) Less(i, j int) bool { return p[i] < p[j] || math.IsNaN(p[i]) && !math.IsNaN(p[j]) } +func (p Float64Slice) Less(i, j int) bool { return p[i] < p[j] || isNaN(p[i]) && !isNaN(p[j]) } func (p Float64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } +// isNaN is a copy of math.IsNaN to avoid a dependency on the math package. +func isNaN(f float64) bool { + return f != f +} + // Sort is a convenience method. func (p Float64Slice) Sort() { Sort(p) } |