Improve sorting
This commit is contained in:
13
utils/sorting/beneficiaries.go
Normal file
13
utils/sorting/beneficiaries.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package sorting
|
||||
|
||||
import (
|
||||
mobilityaccountsstorage "git.coopgo.io/coopgo-platform/mobility-accounts/storage"
|
||||
)
|
||||
|
||||
type BeneficiariesByName []mobilityaccountsstorage.Account
|
||||
|
||||
func (e BeneficiariesByName) Len() int { return len(e) }
|
||||
func (e BeneficiariesByName) Less(i, j int) bool {
|
||||
return e[i].Data["first_name"].(string) < e[j].Data["first_name"].(string)
|
||||
}
|
||||
func (e BeneficiariesByName) Swap(i, j int) { e[i], e[j] = e[j], e[i] }
|
||||
11
utils/sorting/events.go
Normal file
11
utils/sorting/events.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package sorting
|
||||
|
||||
import (
|
||||
agendastorage "git.coopgo.io/coopgo-platform/agenda/storage"
|
||||
)
|
||||
|
||||
type EventsByStartdate []agendastorage.Event
|
||||
|
||||
func (e EventsByStartdate) Len() int { return len(e) }
|
||||
func (e EventsByStartdate) Less(i, j int) bool { return e[i].Startdate.Before(e[j].Startdate) }
|
||||
func (e EventsByStartdate) Swap(i, j int) { e[i], e[j] = e[j], e[i] }
|
||||
15
utils/sorting/groups.go
Normal file
15
utils/sorting/groups.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package sorting
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
groupstorage "git.coopgo.io/coopgo-platform/groups-management/storage"
|
||||
)
|
||||
|
||||
type GroupsByName []groupstorage.Group
|
||||
|
||||
func (a GroupsByName) Len() int { return len(a) }
|
||||
func (a GroupsByName) Less(i, j int) bool {
|
||||
return strings.Compare(a[i].Data["name"].(string), a[j].Data["name"].(string)) < 0
|
||||
}
|
||||
func (a GroupsByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
Reference in New Issue
Block a user