Skip to content

Instantly share code, notes, and snippets.

@didil
Created January 26, 2023 13:33
Show Gist options
  • Save didil/7df1adfed438eda1d637945e801561bd to your computer and use it in GitHub Desktop.
Save didil/7df1adfed438eda1d637945e801561bd to your computer and use it in GitHub Desktop.
go iteration sort no generics
func InsertSortInt(items []int) {
for i := 1; i < len(items); i++ {
// loop through subslices
for j := i; j > 0; j-- {
if items[j] < items[j-1] {
// swap elements if not ordered
items[j], items[j-1] = items[j-1], items[j]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment