@@ -21,18 +21,20 @@ type Interface interface {
21
21
// Less reports whether the element with index i
22
22
// must sort before the element with index j.
23
23
//
24
+ // Less must satisfy [Strict Weak Ordering]. For example:
25
+ // - if both Less(i, j) and Less(j, k) are true, then Less(i, k) must be true as well.
26
+ // - if both Less(i, j) and Less(j, k) are false, then Less(i, k) must be false as well.
27
+ //
24
28
// If both Less(i, j) and Less(j, i) are false,
25
29
// then the elements at index i and j are considered equal.
26
30
// Sort may place equal elements in any order in the final result,
27
31
// while Stable preserves the original input order of equal elements.
28
32
//
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
- //
33
33
// 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.
35
35
// 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
36
38
Less (i , j int ) bool
37
39
38
40
// Swap swaps the elements with indexes i and j.
0 commit comments