forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sort.go
35 lines (26 loc) · 776 Bytes
/
sort.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package prometheus
import dto "github.com/prometheus/client_model/go"
// labelPairSorter implements sort.Interface. It is used to sort a slice of
// dto.LabelPair pointers.
type labelPairSorter []*dto.LabelPair
func (s labelPairSorter) Len() int {
return len(s)
}
func (s labelPairSorter) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s labelPairSorter) Less(i, j int) bool {
return s[i].GetName() < s[j].GetName()
}
// familySorter implements sort.Interface. It is used to sort a slice of
// dto.MetricFamily pointers.
type familySorter []*dto.MetricFamily
func (s familySorter) Len() int {
return len(s)
}
func (s familySorter) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s familySorter) Less(i, j int) bool {
return s[i].GetName() < s[j].GetName()
}