@@ 18,8 18,10 @@ func main() {
// flags
opts := struct {
parser *string
+ new *bool
}{
flag.String("parser", "", "parser to use for files"),
+ flag.Bool("new", false, "sort transactions new to old"),
}
flag.Parse()
@@ 71,10 73,16 @@ func main() {
}
- // sort oldest to newest
- sort.SliceStable(txns, func(i, j int) bool {
- return txns[i].Date().Before(txns[j].Date())
- })
+ // sort transactions
+ if *opts.new {
+ sort.SliceStable(txns, func(i, j int) bool {
+ return txns[i].Date().After(txns[j].Date())
+ })
+ } else {
+ sort.SliceStable(txns, func(i, j int) bool {
+ return txns[i].Date().Before(txns[j].Date())
+ })
+ }
// csv
w := csv.NewWriter(os.Stdout)