You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 30, 2018. It is now read-only.
Go 1.8 adds the following slice helpers to the sort package
Slice(slice interface{}, less func(i, j int) bool)
SliceIsSorted(slice interface{}, less func(i, j int) bool) bool
SliceStable(slice interface{}, less func(i, j int) bool)
It appears we could just check for calls to sort.Slice{,Stable,IsSorted} with a slice (taking into account a possible cast to something that implements sort.Interface). If it's a slice, we can suggest a simplification to sort.Slice{,Stable,IsSorted}.
I can't imagine any conceivable reasons someone may want to ignore the suggestion, as I can't imagine anyone implementing the Len or Swap methods any differently.
Would it be safe to implement this check, and if a maintainer wants to support pre Go 1.8, they can use the ignore flags?
If no-one has any immediate concerns/suggestions/alternatives, I may attempt to implement this check myself soon.
Pre 1.8 to sort a slice of person by age:
Post 1.8 using https://tip.golang.org/pkg/sort/#Slice
The text was updated successfully, but these errors were encountered: