package main import ( "fmt" "sort" ) func main() { fruits := sort.StringSlice{"banana", "apple", "pear", "orange"} sort.Sort(fruits) fmt.Println(fruits) }
[apple banana orange pear]To sort the slice in reverse alphabetical order, you can use `sort.Sort(sort.Reverse(fruits))`. The `sort.StringSlice` type is part of the standard library `sort` package.