1
0
Fork 0

added some sorting to the slices example

This commit is contained in:
Stephen M. McQuay 2012-08-02 14:39:13 -06:00
parent 02944ee3dc
commit 05649fb4d2
1 changed files with 16 additions and 12 deletions

View File

@ -1,10 +1,13 @@
package main
import "fmt"
import "sort"
func main() {
p := []int{2, 3, 5, 7, 11, 13}
p := []int{2, 3, 13, 7, 5, 11}
fmt.Println("p ==", p)
sort.Ints(p)
fmt.Printf("%T p: %v\n", p, p)
for i := 0; i < len(p); i++ {
fmt.Printf("p[%d] == %d\n", i, p[i])
@ -18,4 +21,5 @@ func main() {
v := make([]string, 0)
v = append(v, "hello", "world")
fmt.Printf("%v\n", v)
}