mv to source

This commit is contained in:
Mark McGranaghan
2012-09-29 13:21:57 -07:00
parent c90760c285
commit 7307c6bb0b
118 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
// ## Sorting
// The `sort` package implements sorting for builtins
// and user-defined types. We'll look at some of the
// sorts for builtins here.
package main
import "fmt"
import "sort"
func main() {
// Sort methods are specific to the builtin type.
// Sorting is in-place (doesn't return a new slice).
strs := []string{"c", "a", "b"}
sort.Strings(strs)
fmt.Println(strs)
// Sorting methods are named after the type.
ints := []int{7, 2, 4}
sort.Ints(ints)
fmt.Println(ints)
// Check if a slice is in sorted order.
s := sort.IntsAreSorted(ints)
fmt.Println(s)
}
// todo: general and convenience searching

View File

@@ -0,0 +1,5 @@
$ go run sorting.go
[a b c]
[2 4 7]
true
1