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) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| data | Interface | Collection 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}))}