Skip to content

cmpopts: SortSlice s and SortMaps should accept func(T,T) int signature #365

@dsnet

Description

@dsnet

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions