forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sort.go
33 lines (25 loc) · 899 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
package api
// BuildSliceByCreationTimestamp implements sort.Interface for []Build
// based on the CreationTimestamp field.
type BuildSliceByCreationTimestamp []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 []*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]
}