From 86e8fc0a5bda1e95be79529ef3cca17841e6ef8a Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 3 Dec 2024 15:13:50 -0300 Subject: [PATCH] fix: if sort, sort options alphabetically first --- filter/command.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/filter/command.go b/filter/command.go index 6ae7b28..3cecf2a 100644 --- a/filter/command.go +++ b/filter/command.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "os" + "slices" "strings" "github.com/charmbracelet/bubbles/textinput" @@ -54,6 +55,10 @@ func (o Options) Run() error { options = append(options, tea.WithAltScreen()) } + if o.Sort { + slices.SortStableFunc(o.Options, strings.Compare) + } + var matches []fuzzy.Match if o.Value != "" { i.SetValue(o.Value)