v16.0.0
This commit is contained in:
39
pkg/cloudapi/qospolicy/sorting.go
Normal file
39
pkg/cloudapi/qospolicy/sorting.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package qospolicy
|
||||
|
||||
import "sort"
|
||||
|
||||
// SortByCreatedAt sorts ListQosPolicies by the CreatedAt field in ascending order
|
||||
// If inverse param is set to true, the order is reversed
|
||||
func (lqp ListQoSPolicies) SortByCreatedAt(inverse bool) ListQoSPolicies {
|
||||
if len(lqp.Data) < 2 {
|
||||
return lqp
|
||||
}
|
||||
|
||||
sort.Slice(lqp.Data, func(i, j int) bool {
|
||||
if inverse {
|
||||
return lqp.Data[i].CreatedAt > lqp.Data[j].CreatedAt
|
||||
}
|
||||
|
||||
return lqp.Data[i].CreatedAt < lqp.Data[j].CreatedAt
|
||||
})
|
||||
|
||||
return lqp
|
||||
}
|
||||
|
||||
// SortByUpdatedAt sorts ListQosPolicies by the UpdatedAt field in ascending order
|
||||
// If inverse param is set to true, the order is reversed
|
||||
func (lqp ListQoSPolicies) SortByUpdatedAt(inverse bool) ListQoSPolicies {
|
||||
if len(lqp.Data) < 2 {
|
||||
return lqp
|
||||
}
|
||||
|
||||
sort.Slice(lqp.Data, func(i, j int) bool {
|
||||
if inverse {
|
||||
return lqp.Data[i].UpdatedAt > lqp.Data[j].UpdatedAt
|
||||
}
|
||||
|
||||
return lqp.Data[i].UpdatedAt < lqp.Data[j].UpdatedAt
|
||||
})
|
||||
|
||||
return lqp
|
||||
}
|
||||
Reference in New Issue
Block a user