cmpopts: SortSlice s and SortMaps should accept func(T,T) int signature
dsnet opened this issue · 0 comments
dsnet commented
The stdlib is gradually coalescing around func(T, T) int
over func(T, T) bool
as the function to compare elements. See slices.CompareFunc for example.
For better or worse, the cmpopts.SortSlices
and cmpopts.SortMaps
uses Go reflection to call an arbitrary function (since it predates the introduction of Go generics). One benefit of the non-generic API is that we can support both a "less"-like function and a "compare"-like function.
\cc @icio