From b450b87d0a99e94c01c7a225f6190636ce5c534b Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 20 Nov 2025 14:25:55 -0400 Subject: [PATCH] sort offers with null prices after known prices (#2046) --- .../haveno/core/api/CoreOffersService.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/haveno/core/api/CoreOffersService.java b/core/src/main/java/haveno/core/api/CoreOffersService.java index 3f0c8cf7cd..bdc02911ef 100644 --- a/core/src/main/java/haveno/core/api/CoreOffersService.java +++ b/core/src/main/java/haveno/core/api/CoreOffersService.java @@ -72,7 +72,6 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayList; import java.util.Comparator; -import static java.util.Comparator.comparing; import java.util.List; import java.util.Optional; import java.util.function.Consumer; @@ -87,9 +86,21 @@ public class CoreOffersService { private static final long WAIT_FOR_EDIT_REMOVAL_MS = 5000; - private final Supplier> priceComparator = () -> comparing(Offer::getPrice); - private final Supplier> openOfferPriceComparator = () -> comparing(openOffer -> openOffer.getOffer().getPrice()); - private final Supplier> reversePriceComparator = () -> comparing(Offer::getPrice).reversed(); + private final Supplier> priceComparator = + () -> Comparator.comparing( + Offer::getPrice, + Comparator.nullsLast(Comparator.naturalOrder()) + ); + private final Supplier> openOfferPriceComparator = + () -> Comparator.comparing( + openOffer -> openOffer.getOffer().getPrice(), + Comparator.nullsLast(Comparator.naturalOrder()) + ); + private final Supplier> reversePriceComparator = + () -> Comparator.comparing( + Offer::getPrice, + Comparator.nullsLast(Comparator.naturalOrder()) + ).reversed(); private final CoreContext coreContext; private final KeyRing keyRing;