Skip to content

Commit

Permalink
Fix: sort output of the solver properly
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Richter <[email protected]>
  • Loading branch information
Christian Richter authored and viccuad committed Jul 6, 2021
1 parent 08c2bd9 commit 87f841e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions internal/solver/solver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package solver
import (
"encoding/json"
"fmt"
"sort"
"strings"

"github.com/Masterminds/log-go"
Expand Down Expand Up @@ -175,7 +176,21 @@ func (s *Solver) GeneratePkgSets(model maxsat.Model) {
}
}

func (s *Solver) SortPkgSets() {
sort.Strings(s.PkgResultSet.Inconsistencies)
sort.SliceStable(s.PkgResultSet.PresentUnchanged, func(i, j int) bool {
return s.PkgResultSet.PresentUnchanged[i].ChartName < s.PkgResultSet.PresentUnchanged[j].ChartName
})
sort.SliceStable(s.PkgResultSet.ToInstall, func(i, j int) bool {
return s.PkgResultSet.ToInstall[i].ChartName < s.PkgResultSet.ToInstall[j].ChartName
})
sort.SliceStable(s.PkgResultSet.ToRemove, func(i, j int) bool {
return s.PkgResultSet.ToRemove[i].ChartName < s.PkgResultSet.ToRemove[j].ChartName
})
}

func (s *Solver) FormatOutput(t OutputMode) (output string) {
s.SortPkgSets()
var sb strings.Builder
switch t {
case Table:
Expand Down

0 comments on commit 87f841e

Please sign in to comment.