rewrite: update the slice sort to use built-in lib sort

This commit is contained in:
2026-04-19 14:15:14 +02:00
parent fb5881f26f
commit bef7f85bda

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"log"
"math"
"sort"
"time"
"github.com/charmbracelet/bubbles/key"
@@ -690,13 +691,7 @@ func (m Model) GetCartItemsSlice() []*models.CartItem {
}
// Sort keys to ensure consistent order
for i := 0; i < len(keys); i++ {
for j := i + 1; j < len(keys); j++ {
if keys[i] > keys[j] {
keys[i], keys[j] = keys[j], keys[i]
}
}
}
sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] })
// Build items slice in sorted order
items := make([]*models.CartItem, 0, len(m.Cart))