New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sort: change the main example to use Slice instead of Sort #21989
Comments
This sounds like a good idea. But perhaps we should add a sort.Sort example then, showing a common case where sort.Slice isn't enough. |
Yep, there are 4 examples in the top section. All of them use sort.Sort. So, we would be just changing the most common use-case to sort.Slice. The remaining 3 will still use sort.Sort. This was partly inspired by your CL which replaced lot of sort.Sort usages with sort.Slice. 😄 I just happened to look up the definition of sort.Slice and this idea hit me. |
I see - it sounds like the package examples should mention |
There are already sort.Slice and sort.SliceStable example, they just aren't featured in the top 4 examples: https://golang.org/pkg/sort/#Slice I agree they should have more prominence. |
Exactly. This is about getting sort.Slice some more love. |
Change https://golang.org/cl/65710 mentions this issue: |
Hi,
The topmost example that we see if we open https://golang.org/pkg/sort/ uses the
sort.Sort
function. The use case it solves is the most common one which compares an attribute inside a struct.I think its better to point people to the more comfortable and simple function
sort.Slice
for the most common case.So, that would change -
to
I believe this would lead newcomers who don't know about the new
sort.Slice
function and have just opened the documentation page for the first time, to use a better and simpler option.Would be happy to send a CL if you guys agree to this.
The text was updated successfully, but these errors were encountered: