From d8d3183405999a2ed4c43a8fada76298ad089777 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 15 Mar 2019 16:28:11 -0700 Subject: Further improvements to commodity sorting --- src/commodity.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/commodity.cc') 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); } } -- cgit v1.2.3