Skip to content
masterclass Buddy

Go · Function

slices.Sort

slices.Sort sorts a slice of ordered values in ascending order. It changes the slice in place and places floating-point NaN values before other values.

Last updated

Syntax

func Sort[S ~[]E, E cmp.Ordered](x S)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • slices.SortFunc
  • slices.SortStableFunc
  • slices.IsSorted
  • cmp.Ordered

Source: The Go Programming Language — slices/sort.go. Checked 2026-11-03.