sort checks by name

This commit is contained in:
Andrew Schwartz
2016-03-30 01:12:10 +09:00
parent 1b26b126ab
commit 4cbafefc19

View File

@@ -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 }