util/promlint: simplify sorting function (#6448)

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
Simon Pasquier 2019-12-11 15:45:26 +01:00 committed by GitHub
parent 4df814f509
commit b15dda9e07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -85,13 +85,10 @@ func (l *Linter) Lint() ([]Problem, error) {
// Ensure deterministic output.
sort.SliceStable(problems, func(i, j int) bool {
if problems[i].Metric < problems[j].Metric {
return true
} else if problems[i].Metric > problems[j].Metric {
return false
if problems[i].Metric == problems[j].Metric {
return problems[i].Text < problems[j].Text
}
return problems[i].Text < problems[j].Text
return problems[i].Metric < problems[j].Metric
})
return problems, nil