Standard library / sort

sort.StringSlice

Named slice adapter implementing sort.Interface; conversion shares existing backing storage. Expected stdout: '[a b c]\n'.

Formal Syntax & Structure

go syntaxgo
type StringSlice []string

Working Example

Example Snippetgo
package main
import (  "fmt"  "sort")
func main() {  a := sort.StringSlice([]string{"c", "a", "b"})  sort.Sort(a)  fmt.Println(a)}
Go Reference