-
Notifications
You must be signed in to change notification settings - Fork 7
/
user_sort.go
46 lines (34 loc) · 947 Bytes
/
user_sort.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package storage
// UsersByUsername enables sorting user accounts by Username A-Z
type UsersByUsername []User
func (u UsersByUsername) Len() int {
return len(u)
}
func (u UsersByUsername) Swap(i, j int) {
u[i], u[j] = u[j], u[i]
}
func (u UsersByUsername) Less(i, j int) bool {
return u[i].Username < u[j].Username
}
// UsersByFirstName enables sorting user accounts by First Name A-Z
type UsersByFirstName []User
func (u UsersByFirstName) Len() int {
return len(u)
}
func (u UsersByFirstName) Swap(i, j int) {
u[i], u[j] = u[j], u[i]
}
func (u UsersByFirstName) Less(i, j int) bool {
return u[i].FirstName < u[j].FirstName
}
// UsersByLastName enables sorting user accounts by Last Name A-Z
type UsersByLastName []User
func (u UsersByLastName) Len() int {
return len(u)
}
func (u UsersByLastName) Swap(i, j int) {
u[i], u[j] = u[j], u[i]
}
func (u UsersByLastName) Less(i, j int) bool {
return u[i].LastName < u[j].LastName
}