github.com/tcnksm/go@v0.0.0-20141208075154-439b32936367/src/sort/example_test.go (about)

     1  // Copyright 2011 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package sort_test
     6  
     7  import (
     8  	"fmt"
     9  	"sort"
    10  )
    11  
    12  func ExampleInts() {
    13  	s := []int{5, 2, 6, 3, 1, 4} // unsorted
    14  	sort.Ints(s)
    15  	fmt.Println(s)
    16  	// Output: [1 2 3 4 5 6]
    17  }
    18  
    19  func ExampleReverse() {
    20  	s := []int{5, 2, 6, 3, 1, 4} // unsorted
    21  	sort.Sort(sort.Reverse(sort.IntSlice(s)))
    22  	fmt.Println(s)
    23  	// Output: [6 5 4 3 2 1]
    24  }