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 swap(list []int, firstIndex int) { | |
list[firstIndex], list[firstIndex+1] = list[firstIndex+1], list[firstIndex] | |
} |
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) |
NewerOlder