Go Package slices: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 10: Line 10:
{{External|https://pkg.go.dev/slices#Sort}}
{{External|https://pkg.go.dev/slices#Sort}}
<code>Sort()</code> <font color=darkkhaki>inplace</font> sorts a slice of any ordered type in ascending order. When sorting floating-point numbers, NaNs are ordered before other values.
<code>Sort()</code> <font color=darkkhaki>inplace</font> sorts a slice of any ordered type in ascending order. When sorting floating-point numbers, NaNs are ordered before other values.
<syntaxhighlight lang='go'>
s := []int{0, 42, -10, 8}
slices.Sort(s)
</syntaxhighlight>

Revision as of 00:59, 2 September 2023

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)