Go sort: primitives for sorting slices and collections
Answer: Package sort provides primitives for sorting slices and user-defined collections. An implementation of Interface can be sorted by the routines in this package. IntSlice attaches those methods to []int, sorting in increasing order.
Examples
sort.Ints([]int{3, 1, 2})
Notes
Interface methods refer to elements by integer index. For a common case, IntSlice wraps []int.
Reference list
sortprovides primitives for sorting slices and collections.Interfaceis what custom collections implement.IntSliceattaches those methods to []int.
See also
Claims
- id: C1 claim: Package sort provides primitives for sorting slices and collections. source: S1 evidence: "Package sort provides primitives for sorting slices and user-defined collections."
- id: C2 claim: An Interface implementation can be sorted by this package. source: S2 evidence: "An implementation of Interface can be sorted by the routines in this package."
- id: C3 claim: IntSlice attaches Interface methods to []int. source: S2 evidence: "IntSlice attaches the methods of Interface to []int"
Sources
- [S1] sort package. Go docs. https://pkg.go.dev/sort . License: BSD-3-Clause. Accessed 2026-11-18.
- [S2] sort.go. Go source. https://raw.githubusercontent.com/golang/go/master/src/sort/sort.go . License: BSD-3-Clause. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Go docs, sort package; Go source, sort.go. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Go docs, sort package; Go source, sort.go. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.
Cite this
iinventedlight. 2026. "Go sort: primitives for sorting slices and collections." iinventedlight Library, iil:note:fk9aphkw, version of 2026-11-18. https://iinventedlight.com/library/notes/go-sort/. License: CC-BY-4.0.
@misc{iil_note_fk9aphkw,
author = {{iinventedlight}},
title = {{Go sort: primitives for sorting slices and collections}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/go-sort/},
note = {Permanent ID iil:note:fk9aphkw. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- go-sort.table.json (table; CC-BY-4.0)
- go-sort.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-sort.md.