Navigation Menu

Skip to content

Commit

Permalink
slices: add package-level documentation for less function
Browse files Browse the repository at this point in the history
Document that the less function requires strict weak ordering.

Fixes golang/go#52518

Change-Id: Ia2d5f3137932b4c0fb0da4bfdf12f8d69b2672de
Reviewed-on: https://go-review.googlesource.com/c/exp/+/402534
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Eli Bendersky <eliben@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Keith Randall <khr@google.com>
  • Loading branch information
zhangyunhao116 authored and randall77 committed Apr 28, 2022
1 parent 3bcf042 commit 39d4317
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions slices/slices.go
Expand Up @@ -5,6 +5,11 @@
// Package slices defines various functions useful with slices of any type.
// Unless otherwise specified, these functions all apply to the elements
// of a slice at index 0 <= i < len(s).
//
// Note that the less function in IsSortedFunc, SortFunc, SortStableFunc requires a
// strict weak ordering (https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings),
// or the sorting may fail to sort correctly. A common case is when sorting slices of
// floating-point numbers containing NaN values.
package slices

import "golang.org/x/exp/constraints"
Expand Down

0 comments on commit 39d4317

Please sign in to comment.