From 3273be3dccbdd56035b588f5e7edc5a26544f841 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sat, 31 Jul 2004 02:36:20 -0400 Subject: restore sorting of register reports --- item.cc | 8 +++++--- main.cc | 14 +++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/item.cc b/item.cc index c85ad9ba..11203c10 100644 --- a/item.cc +++ b/item.cc @@ -129,6 +129,7 @@ item_t * walk_entries(entries_list::const_iterator begin, subitem->payee = item->payee; subitem->account = (*j)->account; subitem->value = *(*j); + item->value += subitem->value; item->subitems.push_back(subitem); } @@ -163,19 +164,20 @@ item_t * walk_entries(entries_list::const_iterator begin, struct cmp_items { const node_t * sort_order; - cmp_items(const node_t * _sort_order) : sort_order(_sort_order) {} + cmp_items(const node_t * _sort_order) : sort_order(_sort_order) { + assert(sort_order); + } bool operator()(const item_t * left, const item_t * right) const { assert(left); assert(right); - assert(sort_order); return sort_order->compute(left) < sort_order->compute(right); } }; void item_t::sort(const node_t * sort_order) { - std::sort(subitems.begin(), subitems.end(), cmp_items(sort_order)); + std::stable_sort(subitems.begin(), subitems.end(), cmp_items(sort_order)); } } // namespace ledger diff --git a/main.cc b/main.cc index 9a184ad2..54b65e8e 100644 --- a/main.cc +++ b/main.cc @@ -59,13 +59,13 @@ unsigned int show_balances(std::ostream& out, return headlines; } -void balance_report(std::ostream& out, - item_t * top, - const node_t * predicate, - const node_t * sort_order, - const format_t& format, - const bool show_expanded, - const bool show_subtotals) +void balance_report(std::ostream& out, + item_t * top, + const node_t * predicate, + const node_t * sort_order, + const format_t& format, + const bool show_expanded, + const bool show_subtotals) { if (sort_order) top->sort(sort_order); -- cgit v1.2.3