Skip to content

Commit

Permalink
Implementing stable sort order for search query
Browse files Browse the repository at this point in the history
  • Loading branch information
boggydigital committed Nov 12, 2024
1 parent 614e38e commit 2859d7c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rest/compton_pages/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/boggydigital/compton/consts/color"
"github.com/boggydigital/compton/consts/size"
"github.com/boggydigital/kevlar"
"golang.org/x/exp/maps"
"slices"
"strconv"
"strings"
)
Expand Down Expand Up @@ -52,7 +54,11 @@ func Search(query map[string][]string, ids []string, from, to int, rdx kevlar.Re
var queryFrow *compton.FrowElement
if len(query) > 0 {
queryFrow = compton.Frow(p).FontSize(size.Small)
for prop, vals := range compton_fragments.FormatQuery(query, rdx) {
fq := compton_fragments.FormatQuery(query, rdx)
props := maps.Keys(query)
slices.Sort(props)
for _, prop := range props {
vals := fq[prop]
queryFrow.PropVal(compton_data.PropertyTitles[prop], strings.Join(vals, ","))
}
queryFrow.LinkColor("Clear", "/search", color.Blue)
Expand Down

0 comments on commit 2859d7c

Please sign in to comment.