2011-10-27 01:57:58 +02:00
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package sort_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"sort"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ExampleInts() {
|
2012-01-12 02:31:45 +01:00
|
|
|
s := []int{5, 2, 6, 3, 1, 4} // unsorted
|
2011-10-27 01:57:58 +02:00
|
|
|
sort.Ints(s)
|
|
|
|
fmt.Println(s)
|
2012-03-02 21:01:37 +01:00
|
|
|
// Output: [1 2 3 4 5 6]
|
2011-10-27 01:57:58 +02:00
|
|
|
}
|
2013-07-16 08:54:42 +02:00
|
|
|
|
|
|
|
func ExampleReverse() {
|
|
|
|
s := []int{5, 2, 6, 3, 1, 4} // unsorted
|
|
|
|
sort.Sort(sort.Reverse(sort.IntSlice(s)))
|
|
|
|
fmt.Println(s)
|
|
|
|
// Output: [6 5 4 3 2 1]
|
|
|
|
}
|