github.com/graybobo/golang.org-package-offline-cache@v0.0.0-20200626051047-6608995c132f/x/talks/2014/go4gophers/sort.go (about) 1 // +build OMIT 2 3 package main 4 5 import ( 6 "fmt" 7 "sort" 8 ) 9 10 type IntSlice []int 11 12 func (p IntSlice) Len() int { return len(p) } 13 func (p IntSlice) Less(i, j int) bool { return p[i] < p[j] } 14 func (p IntSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } 15 16 func main() { 17 // START OMIT 18 s := []int{7, 5, 3, 11, 2} 19 sort.Sort(IntSlice(s)) 20 fmt.Println(s) 21 // STOP OMIT 22 }