From 5594631279e57fffb11c62cf4a184277b5181010 Mon Sep 17 00:00:00 2001 From: John Giorshev Date: Thu, 17 Apr 2025 10:26:33 -0400 Subject: [PATCH] sort: clarify doc on less --- src/sort/sort.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/sort/sort.go b/src/sort/sort.go index b27ecabdd57468..a397b2d2b16742 100644 --- a/src/sort/sort.go +++ b/src/sort/sort.go @@ -21,15 +21,14 @@ type Interface interface { // Less reports whether the element with index i // must sort before the element with index j. // + // Less must satisfy strict weak ordering. + // https://en.wikipedia.org/wiki/Weak_ordering#Strict_weak_orderings + // // If both Less(i, j) and Less(j, i) are false, // then the elements at index i and j are considered equal. // Sort may place equal elements in any order in the final result, // while Stable preserves the original input order of equal elements. // - // Less must describe a transitive ordering: - // - if both Less(i, j) and Less(j, k) are true, then Less(i, k) must be true as well. - // - if both Less(i, j) and Less(j, k) are false, then Less(i, k) must be false as well. - // // Note that floating-point comparison (the < operator on float32 or float64 values) // is not a transitive ordering when not-a-number (NaN) values are involved. // See Float64Slice.Less for a correct implementation for floating-point values.