sort users by mtime
parent
623d411b88
commit
b43e94c2ed
9
main.go
9
main.go
|
@ -21,6 +21,7 @@ import (
|
|||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
@ -235,7 +236,11 @@ func getDefaultHTML() ([]byte, error) {
|
|||
return defaultIndexHTML, nil
|
||||
}
|
||||
|
||||
type usersByMtime []*user
|
||||
type byMtime []*user
|
||||
|
||||
func (x byMtime) Len() int { return len(x) }
|
||||
func (x byMtime) Less(i, j int) bool { return x[i].Mtime > x[j].Mtime } // because we want DESC
|
||||
func (x byMtime) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
|
||||
|
||||
func getUsers() (users []*user, err error) {
|
||||
// TODO sort by mtime
|
||||
|
@ -332,6 +337,8 @@ func tdp() (tildeData, error) {
|
|||
return tildeData{}, fmt.Errorf("could not determine uptime: %s", err)
|
||||
}
|
||||
|
||||
sort.Sort(byMtime(users))
|
||||
|
||||
return tildeData{
|
||||
Name: "tilde.town",
|
||||
URL: "https://tilde.town",
|
||||
|
|
Loading…
Reference in New Issue