← All notes

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

See also

Claims

Sources

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

Permanent ID: iil:note:fk9aphkw

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.},
}

Markdown

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.

All artifact files (JSON index)

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.