Last active
May 5, 2020 08:41
-
-
Save cedricconol/44e5e187792d6865bbded10bf7e00eb8 to your computer and use it in GitHub Desktop.
pass function for bubble sort in go
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 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