v11.0.0
This commit is contained in:
@@ -96,3 +96,98 @@ func (lc ListComputes) SortByDeletedTime(inverse bool) ListComputes {
|
||||
|
||||
return lc
|
||||
}
|
||||
|
||||
// SortByCPU sorts ListDeletedComputes by the CPU core amount in ascending order.
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lc ListDeletedComputes) SortByCPU(inverse bool) ListDeletedComputes {
|
||||
if len(lc.Data) < 2 {
|
||||
return lc
|
||||
}
|
||||
|
||||
sort.Slice(lc.Data, func(i, j int) bool {
|
||||
if inverse {
|
||||
return lc.Data[i].CPUs > lc.Data[j].CPUs
|
||||
}
|
||||
|
||||
return lc.Data[i].CPUs < lc.Data[j].CPUs
|
||||
})
|
||||
|
||||
return lc
|
||||
}
|
||||
|
||||
// SortByRAM sorts ListDeletedComputes by the RAM amount in ascending order.
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lc ListDeletedComputes) SortByRAM(inverse bool) ListDeletedComputes {
|
||||
if len(lc.Data) < 2 {
|
||||
return lc
|
||||
}
|
||||
|
||||
sort.Slice(lc.Data, func(i, j int) bool {
|
||||
if inverse {
|
||||
return lc.Data[i].RAM > lc.Data[j].RAM
|
||||
}
|
||||
|
||||
return lc.Data[i].RAM < lc.Data[j].RAM
|
||||
})
|
||||
|
||||
return lc
|
||||
}
|
||||
|
||||
// SortByCreatedTime sorts ListDeletedComputes by the CreatedTime field in ascending order.
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lc ListDeletedComputes) SortByCreatedTime(inverse bool) ListDeletedComputes {
|
||||
if len(lc.Data) < 2 {
|
||||
return lc
|
||||
}
|
||||
|
||||
sort.Slice(lc.Data, func(i, j int) bool {
|
||||
if inverse {
|
||||
return lc.Data[i].CreatedTime > lc.Data[j].CreatedTime
|
||||
}
|
||||
|
||||
return lc.Data[i].CreatedTime < lc.Data[j].CreatedTime
|
||||
})
|
||||
|
||||
return lc
|
||||
}
|
||||
|
||||
// SortByUpdatedTime sorts ListDeletedComputes by the UpdatedTime field in ascending order.
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lc ListDeletedComputes) SortByUpdatedTime(inverse bool) ListDeletedComputes {
|
||||
if len(lc.Data) < 2 {
|
||||
return lc
|
||||
}
|
||||
|
||||
sort.Slice(lc.Data, func(i, j int) bool {
|
||||
if inverse {
|
||||
return lc.Data[i].UpdatedTime > lc.Data[j].UpdatedTime
|
||||
}
|
||||
|
||||
return lc.Data[i].UpdatedTime < lc.Data[j].UpdatedTime
|
||||
})
|
||||
|
||||
return lc
|
||||
}
|
||||
|
||||
// SortByDeletedTime sorts ListDeletedComputes by the DeletedTime field in ascending order.
|
||||
//
|
||||
// If inverse param is set to true, the order is reversed.
|
||||
func (lc ListDeletedComputes) SortByDeletedTime(inverse bool) ListDeletedComputes {
|
||||
if len(lc.Data) < 2 {
|
||||
return lc
|
||||
}
|
||||
|
||||
sort.Slice(lc.Data, func(i, j int) bool {
|
||||
if inverse {
|
||||
return lc.Data[i].DeletedTime > lc.Data[j].DeletedTime
|
||||
}
|
||||
|
||||
return lc.Data[i].DeletedTime < lc.Data[j].DeletedTime
|
||||
})
|
||||
|
||||
return lc
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user