mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
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:
parent
b058b10a94
commit
fed11184c7
1 changed files with 3 additions and 3 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue