Skip to content

Commit 5594631

Browse files
committed
sort: clarify doc on less
1 parent 7b26389 commit 5594631

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/sort/sort.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@ type Interface interface {
2121
// Less reports whether the element with index i
2222
// must sort before the element with index j.
2323
//
24+
// Less must satisfy strict weak ordering.
25+
// https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings
26+
//
2427
// If both Less(i, j) and Less(j, i) are false,
2528
// then the elements at index i and j are considered equal.
2629
// Sort may place equal elements in any order in the final result,
2730
// while Stable preserves the original input order of equal elements.
2831
//
29-
// Less must describe a transitive ordering:
30-
// - if both Less(i, j) and Less(j, k) are true, then Less(i, k) must be true as well.
31-
// - if both Less(i, j) and Less(j, k) are false, then Less(i, k) must be false as well.
32-
//
3332
// Note that floating-point comparison (the < operator on float32 or float64 values)
3433
// is not a transitive ordering when not-a-number (NaN) values are involved.
3534
// See Float64Slice.Less for a correct implementation for floating-point values.

0 commit comments

Comments
 (0)