Order files alphabetically

This commit is contained in:
Laszlo Fogas 2019-06-13 18:09:25 +02:00
parent a3ec40d438
commit 001d645471

View file

@ -5,6 +5,8 @@ import (
"github.com/laszlocph/drone-oss-08/model"
"github.com/laszlocph/drone-oss-08/remote"
"sort"
)
type configFetcher struct {
@ -30,8 +32,16 @@ func (cf *configFetcher) Fetch() ([]*remote.FileMeta, error) {
if direrr != nil {
return nil, direrr
}
sort.Sort(byName(dir))
return dir, nil
}
}
return []*remote.FileMeta{}, nil
}
type byName []*remote.FileMeta
func (a byName) Len() int { return len(a) }
func (a byName) Less(i, j int) bool { return a[i].Name < a[j].Name }
func (a byName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }