sort code

This commit is contained in:
Mark McGranaghan 2012-09-21 08:55:45 -07:00
parent c1addcaab4
commit 5a2e750fe1
2 changed files with 15 additions and 6 deletions

View File

@ -74,3 +74,4 @@ func main() {
// concurrency // concurrency
// reconnection // reconnection
// errors // errors
// redis url

View File

@ -1,12 +1,20 @@
package main package main
import ("fmt"; "sort") import "fmt"
import "sort"
func main() { func main() {
strs := []string{"foo", "bar", "bat"} strs := []string{"c", "a", "b"}
fmt.Println(strs)
fmt.Println()
sort.Strings(strs) sort.Strings(strs)
fmt.Println(strs) fmt.Println(strs)
ints := []int{7, 2, 4}
sort.Ints(ints)
fmt.Println(ints)
} }
/*
$ go run sort.go
[foo bar bat]
[2 4 7]
*/