feat(viewer): sort holdings cards by position weight descending

Display largest position first in the holdings panel for better readability
This commit is contained in:
2026-06-06 22:48:40 +08:00
parent 4d9e12886f
commit 8d8fd71149

View File

@@ -403,7 +403,13 @@ function renderHoldings(day, meta) {
}
let html = '';
for (const code of day.holdings) {
// Sort holdings by weight descending (largest position first)
const sortedHoldings = [...day.holdings].sort((a, b) => {
const wa = day.assets[a] && day.assets[a].weight !== null ? day.assets[a].weight : 0;
const wb = day.assets[b] && day.assets[b].weight !== null ? day.assets[b].weight : 0;
return wb - wa;
});
for (const code of sortedHoldings) {
const a = day.assets[code];
if (!a) continue;
const info = meta.codes[code] || {};