Skip to content

Commit 26fe793

Browse files
committed
sort: clarify doc on less
1 parent 49cdf0c commit 26fe793

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 satisfy [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)