summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-04-28 17:35:25 -0600
committermo khan <mo@mokhan.ca>2025-04-28 17:35:25 -0600
commit43df9387541375638a68a3a1645fc7f6c6a9718c (patch)
tree7de73ad496a0d9e1fd8c1225c23d7fd066b5965b
parentf79995c0825cb754b2fabdd4845a1b94af73ecb1 (diff)
feat: sort the in memory items
-rw-r--r--app/db/in_memory_repository.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/db/in_memory_repository.go b/app/db/in_memory_repository.go
index 5b84dbf..5d8628d 100644
--- a/app/db/in_memory_repository.go
+++ b/app/db/in_memory_repository.go
@@ -1,6 +1,8 @@
package db
import (
+ "sort"
+
"github.com/xlgmokha/x/pkg/x"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/app/domain"
"gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/pls"
@@ -36,5 +38,8 @@ func (r *inMemoryRepository[T]) Save(item T) error {
}
r.items = append(r.items, item)
+ sort.Slice(r.items, func(i, j int) bool {
+ return r.items[i].GetID() > r.items[j].GetID()
+ })
return nil
}