blob: ceadde6a5e1021c355ac1a4a83e7778de48f38f9 [file] [log] [blame]
Zack Williamse940c7a2019-08-21 14:25:39 -07001// Protocol Buffers for Go with Gadgets
2//
3// Copyright (c) 2013, The GoGo Authors. All rights reserved.
4// http://github.com/gogo/protobuf
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are
8// met:
9//
10// * Redistributions of source code must retain the above copyright
11// notice, this list of conditions and the following disclaimer.
12// * Redistributions in binary form must reproduce the above
13// copyright notice, this list of conditions and the following disclaimer
14// in the documentation and/or other materials provided with the
15// distribution.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29package sortkeys
30
31import (
32 "sort"
33)
34
35func Strings(l []string) {
36 sort.Strings(l)
37}
38
39func Float64s(l []float64) {
40 sort.Float64s(l)
41}
42
43func Float32s(l []float32) {
44 sort.Sort(Float32Slice(l))
45}
46
47func Int64s(l []int64) {
48 sort.Sort(Int64Slice(l))
49}
50
51func Int32s(l []int32) {
52 sort.Sort(Int32Slice(l))
53}
54
55func Uint64s(l []uint64) {
56 sort.Sort(Uint64Slice(l))
57}
58
59func Uint32s(l []uint32) {
60 sort.Sort(Uint32Slice(l))
61}
62
63func Bools(l []bool) {
64 sort.Sort(BoolSlice(l))
65}
66
67type BoolSlice []bool
68
69func (p BoolSlice) Len() int { return len(p) }
70func (p BoolSlice) Less(i, j int) bool { return p[j] }
71func (p BoolSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
72
73type Int64Slice []int64
74
75func (p Int64Slice) Len() int { return len(p) }
76func (p Int64Slice) Less(i, j int) bool { return p[i] < p[j] }
77func (p Int64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
78
79type Int32Slice []int32
80
81func (p Int32Slice) Len() int { return len(p) }
82func (p Int32Slice) Less(i, j int) bool { return p[i] < p[j] }
83func (p Int32Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
84
85type Uint64Slice []uint64
86
87func (p Uint64Slice) Len() int { return len(p) }
88func (p Uint64Slice) Less(i, j int) bool { return p[i] < p[j] }
89func (p Uint64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
90
91type Uint32Slice []uint32
92
93func (p Uint32Slice) Len() int { return len(p) }
94func (p Uint32Slice) Less(i, j int) bool { return p[i] < p[j] }
95func (p Uint32Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
96
97type Float32Slice []float32
98
99func (p Float32Slice) Len() int { return len(p) }
100func (p Float32Slice) Less(i, j int) bool { return p[i] < p[j] }
101func (p Float32Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }