cmd/score/score.go: case-insensitive sort
This commit is contained in:
@@ -13,9 +13,10 @@ import (
|
||||
)
|
||||
|
||||
type Item struct {
|
||||
text string
|
||||
score int
|
||||
isnew bool
|
||||
text string
|
||||
lctext string
|
||||
score int
|
||||
isnew bool
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -50,9 +51,10 @@ func main() {
|
||||
x(err)
|
||||
n1, ok := count[aa[1]]
|
||||
items = append(items, Item{
|
||||
text: aa[1],
|
||||
score: n - n1,
|
||||
isnew: !ok,
|
||||
text: aa[1],
|
||||
lctext: strings.ToLower(aa[1]),
|
||||
score: n - n1,
|
||||
isnew: !ok,
|
||||
})
|
||||
}
|
||||
x(scanner.Err())
|
||||
@@ -70,7 +72,7 @@ func main() {
|
||||
if 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 {
|
||||
|
||||
Reference in New Issue
Block a user