Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secondary sort order in Market Offer Lists #4168

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ private void updateChartData() {
.map(OfferBookListItem::getOffer)
.filter(e -> e.getCurrencyCode().equals(selectedTradeCurrencyProperty.get().getCode())
&& e.getDirection().equals(OfferPayload.Direction.BUY))
.sorted(getComparator(false))
.sorted(getComparatorWithSecondarySortOrder(false))
.collect(Collectors.toList());

final Optional<Offer> highestBuyPriceOffer = allBuyOffers.stream()
Expand Down Expand Up @@ -309,7 +309,7 @@ private void updateChartData() {
.map(OfferBookListItem::getOffer)
.filter(e -> e.getCurrencyCode().equals(selectedTradeCurrencyProperty.get().getCode())
&& e.getDirection().equals(OfferPayload.Direction.SELL))
.sorted(getComparator(true))
.sorted(getComparatorWithSecondarySortOrder(true))
.collect(Collectors.toList());

final Optional<Offer> highestSellPriceOffer = allSellOffers.stream()
Expand All @@ -333,7 +333,14 @@ private void updateChartData() {
buildChartAndTableEntries(allSellOffers, OfferPayload.Direction.SELL, sellData, topSellOfferList);
}

private Comparator<Offer> getComparator(boolean reversePrimarySortOrder) {
/**
* Returns a comparator to be used for Offers. Sorts primarily for price and
* secondarily for offer volume.
*
* @param reversePrimarySortOrder
* @return
*/
private Comparator<Offer> getComparatorWithSecondarySortOrder(boolean reversePrimarySortOrder) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this name is preferable: getOfferComparator(...). The problem with getComparator was just that it didn't mention the object of comparison.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not requesting this change, since the whole method should be unnecessary.

Comparator<Offer> primary = Comparator.comparing(Offer::getPrice, (o1, o2) -> {
long a = o1 != null ? o1.getValue() : 0;
long b = o2 != null ? o2.getValue() : 0;
Expand Down