aboutsummaryrefslogtreecommitdiff
path: root/country.go
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2020-03-23 04:29:12 +0000
committerFelix Hanley <felix@userspace.com.au>2020-03-23 04:29:12 +0000
commit8eb8549b9121e3708c697361c83f39c1dfc846b5 (patch)
treee1a8c092fcd891f56a1a787ea4e176f18214248e /country.go
parentac6468f9eac688a2fb379ea332fd45490cf80cf4 (diff)
downloadsws-8eb8549b9121e3708c697361c83f39c1dfc846b5.tar.gz
sws-8eb8549b9121e3708c697361c83f39c1dfc846b5.tar.bz2
Create CSS using SASS and add subfilters
Diffstat (limited to 'country.go')
-rw-r--r--country.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/country.go b/country.go
index d5bbe48..f3d49b0 100644
--- a/country.go
+++ b/country.go
@@ -2,6 +2,7 @@ package sws
import (
"net"
+ "sort"
maxminddb "github.com/oschwald/maxminddb-golang"
)
@@ -13,7 +14,7 @@ type Country struct {
type CountrySet []*Country
-func NewCountrySet(hs *HitSet) CountrySet {
+func NewCountrySet(hs *HitSet) *CountrySet {
tmp := make(map[string]*Country)
for _, h := range hs.Hits() {
if h.CountryCode == nil {
@@ -43,7 +44,14 @@ func NewCountrySet(hs *HitSet) CountrySet {
out[i] = b
i++
}
- return CountrySet(out)
+ cs := CountrySet(out)
+ return &cs
+}
+
+func (cs *CountrySet) SortByHits() {
+ sort.Slice(*cs, func(i, j int) bool {
+ return (*cs)[i].hitSet.Count() > (*cs)[j].hitSet.Count()
+ })
}
func (c Country) Label() string {