Standard library / sort

sort.Strings()

Sorts the slice ascending in place; no stability guarantee. Expected stdout: '[a b c]\n'.

Formal Syntax & Structure

go syntaxgo
func Strings(x []string)

Parameters & Attributes

NameTypeDescription
x[]stringInput value or collection to process.

Working Example

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