cmd/score/score.go: case-insensitive sort
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user