Skip to content

Instantly share code, notes, and snippets.

@bobbydeveaux
Created March 13, 2014 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobbydeveaux/9537430 to your computer and use it in GitHub Desktop.
Save bobbydeveaux/9537430 to your computer and use it in GitHub Desktop.
Go Bubble Sort
package main
// import "fmt"
func main() {
for c := 0; c < 1000000; c++ {
bubble();
}
}
func bubble() {
array := [...]int16{3,4,1,3,5,1,92,2,4124,424,52,12}
for i := 0; i < len(array); i++ {
for y := 0; y < len(array) - 1; y++ {
if array[y+1] < array[y] {
t := array[y]
array[y] = array[y+1]
array[y+1] = t
}
}
}
// fmt.Print(array);
// fmt.Print("\n");
}
@bobbydeveaux
Copy link
Author

GO
$ time ./bubble

real 0m0.313s
real 0m0.313s
real 0m0.314s
real 0m0.313s
real 0m0.312s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment