]> Cypherpunks.ru repositories - gostls13.git/commit
slices: add sorting and comparison functions
authorEli Bendersky <eliben@golang.org>
Fri, 19 May 2023 17:10:21 +0000 (10:10 -0700)
committerEli Bendersky <eliben@google.com>
Tue, 23 May 2023 23:33:29 +0000 (23:33 +0000)
commit0df681248862a34ff1233cdc4cf0b036e4761652
tree2b0f8384198d97d23c7d1ee7d28fa9f43ed535f3
parent6b7aab7750a8b41b15bac4d598470883c245a0d7
slices: add sorting and comparison functions

Now that the `cmp` package exists, sorting and comparison functions from
`x/exp/slices` can be ported to the standard library, using the
`cmp.Ordered` type and the `cmp.Less` and `cmp.Compare` functions.

This move also includes adjustments to the discussions in #60091 w.r.t.
NaN handling and cmp vs. less functions, and adds Min/Max functions.
The final API is taken from
https://github.com/golang/go/issues/60091#issuecomment-1553850782

Updates #60091

Change-Id: Id7e6c88035b60d4ddd0c48dd82add8e8bc4e22d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/496078
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
Run-TryBot: Eli Benderskyā€ˇ <eliben@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
api/next/60091.txt [new file with mode: 0644]
src/go/build/deps_test.go
src/slices/slices.go
src/slices/slices_test.go
src/slices/sort.go [new file with mode: 0644]
src/slices/sort_benchmark_test.go [new file with mode: 0644]
src/slices/sort_test.go [new file with mode: 0644]
src/slices/zsortanyfunc.go [new file with mode: 0644]
src/slices/zsortordered.go [new file with mode: 0644]
src/sort/gen_sort_variants.go