Standard library / sort
sort.IntsAreSorted()
Reports whether the slice is already in ascending order. Expected stdout: 'true false\n'.
Formal Syntax & Structure
go syntaxgo
func IntsAreSorted(x []int) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| x | []int | 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.IntsAreSorted([]int{1, 2, 3}), sort.IntsAreSorted([]int{3, 1, 2}))}