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

Fix sorting for unrelated stats #7303

Merged
merged 3 commits into from
Jan 24, 2024
Merged
Changes from all commits
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
23 changes: 8 additions & 15 deletions src/Classes/CalcBreakdownControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ function CalcBreakdownClass:AddBreakdownSection(sectionData)
local rowList = copyTable(breakdown.rowList, true)
local colKey = breakdown.colList[1].key
table.sort(rowList, function(a, b)
if a.reqNum then
return a.reqNum > b.reqNum
end
return a[colKey] > b[colKey]
end)

Expand Down Expand Up @@ -300,29 +303,19 @@ function CalcBreakdownClass:AddModSection(sectionData, modList)
}
t_insert(self.sectionList, section)

table.sort(rowList, function(a, b)
-- Sort Modifiers by descending value
if type(a.value) == 'number' and type(b.value) == 'number' then
return b.value < a.value
end
if type(a.value) == 'boolean' and type(b.value) == 'boolean' then
return a.value and not b.value
end
return false
end)

if not modList and not sectionData.modType then
-- Sort modifiers by type
for i, row in ipairs(rowList) do
row.index = i
end
table.sort(rowList, function(a, b)
if a.mod.type == b.mod.type then
return a.index < b.index
return a.mod.name > b.mod.name or a.mod.name == b.mod.name and a.value > b.value
else
return a.mod.type < b.mod.type
end
end)
else -- Sort modifiers by value
table.sort(rowList, function(a, b)
return a.mod.name > b.mod.name or a.mod.name == b.mod.name and a.value > b.value
end)
end

local sourceTotals = { }
Expand Down
Loading