Skip to content

Commit a995269

Browse files
jagprog5gopherbot
authored andcommitted
sort: clarify Less doc
clarifies the requirements for Less Fixes #73420 Change-Id: I7d49b10fad78c618d946b3bb161ce19680ede47a GitHub-Last-Rev: 7a49ad8 GitHub-Pull-Request: #74333 Reviewed-on: https://go-review.googlesource.com/c/go/+/683275 Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Keith Randall <[email protected]> Auto-Submit: Keith Randall <[email protected]> Reviewed-by: Carlos Amedee <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 6c3b5a2 commit a995269

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/sort/sort.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ type Interface interface {
2626
// Sort may place equal elements in any order in the final result,
2727
// while Stable preserves the original input order of equal elements.
2828
//
29-
// Less must describe a transitive ordering:
29+
// Less must describe a [Strict Weak Ordering]. For example:
3030
// - if both Less(i, j) and Less(j, k) are true, then Less(i, k) must be true as well.
3131
// - if both Less(i, j) and Less(j, k) are false, then Less(i, k) must be false as well.
3232
//
3333
// Note that floating-point comparison (the < operator on float32 or float64 values)
34-
// is not a transitive ordering when not-a-number (NaN) values are involved.
34+
// is not a strict weak ordering when not-a-number (NaN) values are involved.
3535
// See Float64Slice.Less for a correct implementation for floating-point values.
36+
//
37+
// [Strict Weak Ordering]: https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings
3638
Less(i, j int) bool
3739

3840
// Swap swaps the elements with indexes i and j.

0 commit comments

Comments
 (0)