forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sort.go
37 lines (28 loc) · 986 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
36
37
package buildapihelpers
import (
buildv1 "github.com/openshift/api/build/v1"
)
// BuildSliceByCreationTimestamp implements sort.Interface for []Build
// based on the CreationTimestamp field.
type BuildSliceByCreationTimestamp []buildv1.Build
func (b BuildSliceByCreationTimestamp) Len() int {
return len(b)
}
func (b BuildSliceByCreationTimestamp) Less(i, j int) bool {
return b[i].CreationTimestamp.Before(&b[j].CreationTimestamp)
}
func (b BuildSliceByCreationTimestamp) Swap(i, j int) {
b[i], b[j] = b[j], b[i]
}
// BuildPtrSliceByCreationTimestamp implements sort.Interface for []*Build
// based on the CreationTimestamp field.
type BuildPtrSliceByCreationTimestamp []*buildv1.Build
func (b BuildPtrSliceByCreationTimestamp) Len() int {
return len(b)
}
func (b BuildPtrSliceByCreationTimestamp) Less(i, j int) bool {
return b[i].CreationTimestamp.Before(&b[j].CreationTimestamp)
}
func (b BuildPtrSliceByCreationTimestamp) Swap(i, j int) {
b[i], b[j] = b[j], b[i]
}