summaryrefslogtreecommitdiff
path: root/src/commodity.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2019-03-15 16:28:11 -0700
committerJohn Wiegley <johnw@newartisans.com>2019-03-15 16:28:11 -0700
commitd8d3183405999a2ed4c43a8fada76298ad089777 (patch)
treed17438a53fe0429e27ec49898621263e784a0b1a /src/commodity.cc
parent3ec91f44a52827257685a5e5cf51f11d8ca138a0 (diff)
downloadfork-ledger-d8d3183405999a2ed4c43a8fada76298ad089777.tar.gz
fork-ledger-d8d3183405999a2ed4c43a8fada76298ad089777.tar.bz2
fork-ledger-d8d3183405999a2ed4c43a8fada76298ad089777.zip
Further improvements to commodity sorting
Diffstat (limited to 'src/commodity.cc')
-rw-r--r--src/commodity.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/commodity.cc b/src/commodity.cc
index d6b52754..cf31886e 100644
--- a/src/commodity.cc
+++ b/src/commodity.cc
@@ -461,16 +461,18 @@ bool commodity_t::compare_by_commodity::operator()(const amount_t * left,
amount_t rightprice(*arightcomm.details.price);
if (leftprice.commodity() == rightprice.commodity()) {
- DEBUG("commodity.compare", "lot commodities match, comparing on sign");
- return (leftprice - rightprice).sign() < 0;
+ DEBUG("commodity.compare",
+ "both have price, commodities match, comparing amount");
+ return leftprice < rightprice;
} else {
// Since we have two different amounts, there's really no way
// to establish a true sorting order; we'll just do it based
// on the numerical values.
leftprice.clear_commodity();
rightprice.clear_commodity();
- DEBUG("commodity.compare", "lot commodities don't match, comparing on sign");
- return (leftprice - rightprice).sign() < 0;
+ DEBUG("commodity.compare",
+ "both have price, commodities don't match, recursing");
+ return commodity_t::compare_by_commodity()(&leftprice, &rightprice);
}
}