Skip to content

docs: update README example to use slices.IsSorted and slices.Sort#91

Merged
flyingmutant merged 1 commit intoflyingmutant:masterfrom
mi-wada:docs/use-slices-is-sorted
Jan 27, 2026
Merged

docs: update README example to use slices.IsSorted and slices.Sort#91
flyingmutant merged 1 commit intoflyingmutant:masterfrom
mi-wada:docs/use-slices-is-sorted

Conversation

@mi-wada
Copy link
Copy Markdown
Contributor

@mi-wada mi-wada commented Jan 26, 2026

slices.IsSorted is a modern alternative to sort.StringsAreSorted:

$ go doc sort.StringsAreSorted
package sort // import "sort"

func StringsAreSorted(x []string) bool
    StringsAreSorted reports whether the slice x is sorted in increasing order.

    Note: as of Go 1.22, this function simply calls slices.IsSorted.

slices.Sort:

$ go doc sort.Strings
package sort // import "sort"

func Strings(x []string)
    Strings sorts a slice of strings in increasing order.

    Note: as of Go 1.22, this function simply calls slices.Sort.

Copilot AI review requested due to automatic review settings January 26, 2026 03:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request updates the README example to use the modern slices.IsSorted function instead of the deprecated sort.StringsAreSorted function, following Go 1.22+ best practices.

Changes:

  • Updated the example code to replace sort.StringsAreSorted(s) with slices.IsSorted(s)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mi-wada mi-wada force-pushed the docs/use-slices-is-sorted branch from 9535bd8 to d74b35a Compare January 26, 2026 03:59
@mi-wada mi-wada changed the title docs: update README example to use slices.IsSorted docs: update README example to use slices.IsSorted and slices.Sort Jan 26, 2026
slices.IsSorted is a modern alternative to sort.StringsAreSorted:
```
$ go doc sort.StringsAreSorted
package sort // import "sort"

func StringsAreSorted(x []string) bool
    StringsAreSorted reports whether the slice x is sorted in increasing order.

    Note: as of Go 1.22, this function simply calls slices.IsSorted.
```

slices.Sort:
```
$ go doc sort.Strings
package sort // import "sort"

func Strings(x []string)
    Strings sorts a slice of strings in increasing order.

    Note: as of Go 1.22, this function simply calls slices.Sort.
```
@mi-wada mi-wada force-pushed the docs/use-slices-is-sorted branch from d74b35a to a0051ca Compare January 26, 2026 04:01
@flyingmutant flyingmutant merged commit 2f95a47 into flyingmutant:master Jan 27, 2026
14 checks passed
@mi-wada mi-wada deleted the docs/use-slices-is-sorted branch January 27, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants