Sort number column

This commit is contained in:
Dapoolp 2025-08-27 10:56:27 +02:00
parent a391470ad0
commit fc3db9b5b1
2 changed files with 6 additions and 4 deletions

View file

@ -437,11 +437,13 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
const newOrder = [...itemList].reverse().sort((a, b) => {
const aProp = a.querySelector(`[data-item-key="${key}"]`),
bProp = b.querySelector(`[data-item-key="${key}"]`);
bProp = b.querySelector(`[data-item-key="${key}"]`),
aValue = isNaN(aProp.innerText) ? aProp.innerText : Number(aProp.innerText),
bValue = isNaN(bProp.innerText) ? bProp.innerText : Number(bProp.innerText);
if (type === 'DESC') {
return aProp.innerText < bProp.innerText ? 1 : -1;
return aValue < bValue ? 1 : -1;
} else {
return aProp.innerText > bProp.innerText ? 1 : -1;
return aValue > bValue ? 1 : -1;
}
});

View file

@ -57,7 +57,7 @@
<div class="item-list-img"></div>
<div class="item-list-name" data-sort-key="name" data-sort-type="ASC" data-action="sortList">{{localize 'DAGGERHEART.UI.ItemBrowser.columnName'}}</div>
{{#each menu.data.columns}}
<span data-sort-key="{{key}}" data-sort-type="" data-action="sortList">{{localize label}}</span>
<div data-sort-key="{{key}}" data-sort-type="" data-action="sortList">{{localize label}}</div>
{{/each}}
</div>
{{/if}}