1
0
mirror of https://github.com/golang/go synced 2024-09-23 19:20:13 -06:00
go/api/next/60091.txt
Eli Bendersky 0df6812488 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>
2023-05-23 23:33:29 +00:00

14 lines
955 B
Plaintext

pkg slices, func BinarySearchFunc[$0 interface{}, $1 interface{}]([]$0, $1, func($0, $1) int) (int, bool) #60091
pkg slices, func BinarySearch[$0 cmp.Ordered]([]$0, $0) (int, bool) #60091
pkg slices, func CompareFunc[$0 interface{}, $1 interface{}]([]$0, []$1, func($0, $1) int) int #60091
pkg slices, func Compare[$0 cmp.Ordered]([]$0, []$0) int #60091
pkg slices, func IsSortedFunc[$0 interface{}]([]$0, func($0, $0) int) bool #60091
pkg slices, func IsSorted[$0 cmp.Ordered]([]$0) bool #60091
pkg slices, func MaxFunc[$0 interface{}]([]$0, func($0, $0) int) $0 #60091
pkg slices, func Max[$0 cmp.Ordered]([]$0) $0 #60091
pkg slices, func MinFunc[$0 interface{}]([]$0, func($0, $0) int) $0 #60091
pkg slices, func Min[$0 cmp.Ordered]([]$0) $0 #60091
pkg slices, func SortFunc[$0 interface{}]([]$0, func($0, $0) int) #60091
pkg slices, func SortStableFunc[$0 interface{}]([]$0, func($0, $0) int) #60091
pkg slices, func Sort[$0 cmp.Ordered]([]$0) #60091