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

1 Answer

0 votes
package main 
  
import ( 
    "fmt"
    "sort"
) 
  
func main() { 
    slice := []string{"c", "c++", "go", "java", "php", "python"} 

    fmt.Println(sort.StringsAreSorted(slice)) 
} 
 

  
/*
run:
   
true

*/

 



answered Aug 17, 2020 by avibootz
...