Have records.Less express the order we want directly.

The ordering is descending by count, then ascending by cc. Express that
directly, rather than specifying the opposite ordering and using
sort.Reverse.
This commit is contained in:
David Fifield 2025-08-15 18:00:38 +00:00
parent b058b10a94
commit fed11184c7

View file

@ -35,9 +35,9 @@ func (r records) Len() int { return len(r) }
func (r records) Swap(i, j int) { r[i], r[j] = r[j], r[i] }
func (r records) Less(i, j int) bool {
if r[i].count == r[j].count {
return r[i].cc > r[j].cc
return r[i].cc < r[j].cc
}
return r[i].count < r[j].count
return r[i].count > r[j].count
}
type Metrics struct {
@ -197,7 +197,7 @@ func displayCountryStats(m *sync.Map, binned bool) string {
}
return true
})
sort.Sort(sort.Reverse(rs))
sort.Sort(rs)
for _, r := range rs {
count := uint64(r.count)
if binned {