This commit is contained in:
asteam
2025-09-26 19:17:30 +03:00
parent 48e2b0f2f9
commit 1ccc37a104
1022 changed files with 6440 additions and 1688 deletions

View File

@@ -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
}