Skip to content

Commit d4d07f0

Browse files
hdurand0710mjuraga
authored andcommitted
MINOR: always start to sort sections by name
Even if some Dependency check or Circular check fails, we still perform a sorting by name.
1 parent 898a53c commit d4d07f0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

config-parser/sorter/sort.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ type Section struct {
3333
// - sort by Name
3434
// - if there is a dependency, section is moved after the one it depends on
3535
func Sort(sections []Section) error {
36+
// first sort by name
37+
sort.SliceStable(sections, func(i, j int) bool {
38+
return sections[i].Name < sections[j].Name
39+
})
40+
3641
// first check that all dependencies exist
3742
for _, section := range sections {
3843
if section.From == "" {
@@ -56,10 +61,6 @@ func Sort(sections []Section) error {
5661
}
5762
}
5863

59-
// first sort by name
60-
sort.SliceStable(sections, func(i, j int) bool {
61-
return sections[i].Name < sections[j].Name
62-
})
6364
// then go through list and check for circular dependencies
6465
sortByFrom(0, sections)
6566
// done

0 commit comments

Comments
 (0)