Created
January 26, 2023 13:33
-
-
Save didil/7df1adfed438eda1d637945e801561bd to your computer and use it in GitHub Desktop.
go iteration sort no generics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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