Standard library / sort
sort.StringsAreSorted()
Reports whether the slice is already in ascending order. Expected stdout: 'true false\n'.
Formal Syntax & Structure
go syntaxgo
func StringsAreSorted(x []string) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | []string | Input value or collection to process. |
Return Value
bool
Reports whether the slice is already in ascending order.
Working Example
Example Snippetgo
package main
import ( "fmt" "sort")
func main() { fmt.Println(sort.StringsAreSorted([]string{"a", "b", "c"}), sort.StringsAreSorted([]string{"c", "a", "b"}))}