Skip to content

Instantly share code, notes, and snippets.

@cedricconol
Last active May 5, 2020 08:41
Show Gist options
  • Save cedricconol/44e5e187792d6865bbded10bf7e00eb8 to your computer and use it in GitHub Desktop.
Save cedricconol/44e5e187792d6865bbded10bf7e00eb8 to your computer and use it in GitHub Desktop.
pass function for bubble sort in go
func pass(list []int, ascending bool) {
var N int = len(list)
for i := 0; i < N-1; i++ {
var firstElement int = list[i]
var secondElement int = list[i+1]
if ascending == true {
if firstElement > secondElement {
swap(list, i)
}
} else {
if firstElement < secondElement {
swap(list, i)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment