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) bool

Parameters & Attributes

NameTypeDescription
x[]stringInput 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"}))}
Go Reference