Skip to content

Commit

Permalink
Alphabetize budgets when print balances (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
marstr authored Mar 11, 2019
1 parent 8f4c7d0 commit 81df8fb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os"
"path"
"path/filepath"
"sort"
"time"

"github.com/marstr/envelopes"
Expand Down Expand Up @@ -156,7 +157,15 @@ func writeBudgetBalances(_ context.Context, output io.Writer, budget envelopes.B
if err != nil {
return
}
for name, child := range budget.Children {

childNames := make([]string, 0, len(budget.Children))
for name := range budget.Children {
childNames = append(childNames, name)
}
sort.Strings(childNames)

for _, name := range childNames {
child := budget.Children[name]
_, err = fmt.Fprintf(output, "\t%s: %s\n", name, child.RecursiveBalance())
if err != nil {
return
Expand Down

0 comments on commit 81df8fb

Please sign in to comment.