| 1 |
// Copyright 2013 The Go Authors. |
| 2 |
// Copyright 2015 Randall Farmer. |
| 3 |
// All rights reserved. |
| 4 |
// Use of this source code is governed by a BSD-style |
| 5 |
// license that can be found in the LICENSE file. |
| 6 |
|
| 7 |
package sorts_test |
| 8 |
|
| 9 |
import ( |
| 10 |
"fmt" |
| 11 |
"github.com/twotwotwo/sorts" |
| 12 |
"github.com/twotwotwo/sorts/sortutil" |
| 13 |
) |
| 14 |
|
| 15 |
func Example_flip() { |
| 16 |
scores := []int{39, 492, 4912, 39, -10, 4, 92} |
| 17 |
data := sortutil.IntSlice(scores) |
| 18 |
data.Sort() |
| 19 |
sorts.Flip(data) // high scores first |
| 20 |
fmt.Println(scores) |
| 21 |
// Output: [4912 492 92 39 39 4 -10] |
| 22 |
} |