From bef7f85bda4986c7d34e90fe67de755d74125bdd Mon Sep 17 00:00:00 2001 From: marcusDenslow Date: Sun, 19 Apr 2026 14:15:14 +0200 Subject: [PATCH] rewrite: update the slice sort to use built-in lib sort --- pkg/tui/model.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/tui/model.go b/pkg/tui/model.go index 8a54c1c..4b9873f 100644 --- a/pkg/tui/model.go +++ b/pkg/tui/model.go @@ -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))