Standard library / sort

sort.IsSorted()

Checks whether the collection is ordered according to its Less method. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func IsSorted(data Interface) bool

Parameters & Attributes

NameTypeDescription
dataInterfaceCollection implementing sort.Interface.

Return Value

bool

Checks whether the collection is ordered according to its Less method.

Working Example

Example Snippetgo
package main
import (  "fmt"  "sort")
func main() {  fmt.Println(sort.IsSorted(sort.IntSlice{1, 2, 2}))}
Go Reference