Go Package slices

From NovaOrdis Knowledge Base
Revision as of 22:55, 26 April 2024 by Ovidiu (talk | contribs) (→‎Sort())
Jump to navigation Jump to search

External

Internal

Overview

Sorting

Sort()

https://pkg.go.dev/slices#Sort

Sort() inplace sorts a slice of any ordered type in ascending order. When sorting floating-point numbers, NaNs are ordered before other values.

s := []int{0, 42, -10, 8}
slices.Sort(s)

Contains()

https://pkg.go.dev/slices#Contains
s := []int{0, 42, -10, 8}
slices.Contains(s)