diff --git a/handlers/checks.go b/handlers/checks.go index 44e2210..fdc35fc 100644 --- a/handlers/checks.go +++ b/handlers/checks.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "path/filepath" + "sort" "strings" "time" @@ -195,9 +196,17 @@ func newChecksResp(repo string, forceRefresh bool) (checksResp, error) { } } + sort.Sort(ByName(resp.Checks)) resp.Average = total resp.Issues = len(issues) resp.Grade = grade(total * 100) return resp, nil } + +// ByName implements sorting for checks alphabetically by name +type ByName []score + +func (a ByName) Len() int { return len(a) } +func (a ByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a ByName) Less(i, j int) bool { return a[i].Name < a[j].Name }