rules: Fix sorting of result from (*Manager).RuleGroups (#5260)

The previous code was defective in that it never sorted groups within a
file due to doing a multi-key sort incorrectly.

Signed-off-by: David Symonds <dsymonds@gmail.com>
This commit is contained in:
David Symonds 2019-02-23 19:51:44 +11:00 committed by Julius Volz
parent e72c875e63
commit 46361a7c85

View file

@ -861,8 +861,12 @@ func (m *Manager) RuleGroups() []*Group {
rgs = append(rgs, g)
}
// Sort rule groups by file, then by name.
sort.Slice(rgs, func(i, j int) bool {
return rgs[i].file < rgs[j].file && rgs[i].name < rgs[j].name
if rgs[i].file != rgs[j].file {
return rgs[i].file < rgs[j].file
}
return rgs[i].name < rgs[j].name
})
return rgs