• Tom Levy's avatar
    sort: fix mix-up between "!less" and "greater" in examples · 2bba2671
    Tom Levy authored
    If Less(a, b) returns true when a is less than b, the correct way to
    check if a is greater than b is to use Less(b, a). It is wrong to use
    !Less(a, b) because that checks if a is greater than *or equal to* b.
    
    1. The decreasingDistance function in Example_sortKeys makes this
       mistake. Fix it.
    
    2. The documentation of multiSorter.Less says it loops along the less
       functions until it finds a comparison "that is either Less or
       !Less". This is nonsense, because (Less(a, b) or !Less(a, b)) is
       always true. Fix the documentation to say that it finds a
       comparison "that discriminates between the two items (one is less
       than the other)". The implementation already does this correctly.
    
    Change-Id: If52b79f68e4fdb0d1095edf29bdecdf154a61b8d
    Reviewed-on: https://go-review.googlesource.com/57752Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    Run-TryBot: Ian Lance Taylor <iant@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    2bba2671
Name
Last commit
Last update
..
example_interface_test.go Loading commit data...
example_keys_test.go Loading commit data...
example_multi_test.go Loading commit data...
example_search_test.go Loading commit data...
example_test.go Loading commit data...
example_wrapper_test.go Loading commit data...
export_test.go Loading commit data...
genzfunc.go Loading commit data...
search.go Loading commit data...
search_test.go Loading commit data...
sort.go Loading commit data...
sort_test.go Loading commit data...
zfuncversion.go Loading commit data...