cmd/score/score.go: case-insensitive sort

This commit is contained in:
Peter Kleiweg
2026-03-25 17:46:31 +01:00
parent 2390752ba4
commit 9686b8b846

View File

@@ -13,9 +13,10 @@ import (
) )
type Item struct { type Item struct {
text string text string
score int lctext string
isnew bool score int
isnew bool
} }
var ( var (
@@ -50,9 +51,10 @@ func main() {
x(err) x(err)
n1, ok := count[aa[1]] n1, ok := count[aa[1]]
items = append(items, Item{ items = append(items, Item{
text: aa[1], text: aa[1],
score: n - n1, lctext: strings.ToLower(aa[1]),
isnew: !ok, score: n - n1,
isnew: !ok,
}) })
} }
x(scanner.Err()) x(scanner.Err())
@@ -70,7 +72,7 @@ func main() {
if items[i].score != items[j].score { if items[i].score != items[j].score {
return items[i].score > items[j].score return items[i].score > items[j].score
} }
return items[i].text < items[j].text return items[i].lctext < items[j].lctext
}) })
for _, item := range items { for _, item := range items {