Skip to content

Commit 3a438c0

Browse files
committed
Classic: Cancelling: Put auctions with bids on them at the top
1 parent 15a859e commit 3a438c0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Source_LegacyAH/Tabs/DataProviders/Cancelling.lua

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ local function GroupAuctions(allAuctions)
188188
local seenDetails = {}
189189

190190
local results = {}
191-
for _, auction in ipairs(allAuctions) do
191+
for index, auction in ipairs(allAuctions) do
192192
local newEntry = {
193193
itemLink = auction.itemLink,
194194
unitPrice = Auctionator.Utilities.ToUnitPrice(auction),
@@ -201,6 +201,7 @@ local function GroupAuctions(allAuctions)
201201
minBid = auction.info[Auctionator.Constants.AuctionItemInfo.MinBid],
202202
bidder = auction.info[Auctionator.Constants.AuctionItemInfo.Bidder],
203203
timeLeft = auction.timeLeft,
204+
index = index,
204205
}
205206
if newEntry.itemLink ~= nil then
206207
local key = ToUniqueKey(newEntry)
@@ -213,6 +214,18 @@ local function GroupAuctions(allAuctions)
213214
end
214215
end
215216

217+
table.sort(results, function(a, b)
218+
if a.bidAmount > 0 and b.bidAmount == 0 then
219+
return true
220+
elseif b.bidAmount > 0 and a.bidAmount == 0 then
221+
return false
222+
elseif a.bidAmount > 0 and b.bidAmount > 0 then
223+
return a.bidAmount > b.bidAmount
224+
else
225+
return a.index < b.index
226+
end
227+
end)
228+
216229
return results
217230
end
218231

0 commit comments

Comments
 (0)