diff options
| author | Felix Hanley <felix@userspace.com.au> | 2020-03-23 04:29:12 +0000 |
|---|---|---|
| committer | Felix Hanley <felix@userspace.com.au> | 2020-03-23 04:29:12 +0000 |
| commit | 8eb8549b9121e3708c697361c83f39c1dfc846b5 (patch) | |
| tree | e1a8c092fcd891f56a1a787ea4e176f18214248e /country.go | |
| parent | ac6468f9eac688a2fb379ea332fd45490cf80cf4 (diff) | |
| download | sws-8eb8549b9121e3708c697361c83f39c1dfc846b5.tar.gz sws-8eb8549b9121e3708c697361c83f39c1dfc846b5.tar.bz2 | |
Create CSS using SASS and add subfilters
Diffstat (limited to 'country.go')
| -rw-r--r-- | country.go | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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 { |
