How to check if a slice of int values is sorted in Go

1 Answer

0 votes
package main
   
import (
    "fmt"
    "sort"
)

func main() {
    slice := []int{4, 6, 12, 100, 150, 500, 2000}
 
    fmt.Println(sort.IntsAreSorted(slice))
} 
 

  
/*
run:
   
true

*/

 



answered Aug 17, 2020 by avibootz
...