Sort merchant inventories lexicographically by (quality, name, quantity)

in details mode.
This commit is contained in:
Avi Weinstock 2023-01-13 22:13:13 -05:00
parent 8facf7b58d
commit 6899023fde

View File

@ -360,7 +360,17 @@ impl<'a> InventoryScroller<'a> {
};
let mut i = 0;
for (pos, item) in self.inventory.slots_with_id() {
let mut items = self.inventory.slots_with_id().collect::<Vec<_>>();
if self.details_mode && !self.is_us {
items.sort_by_cached_key(|(_, item)| {
(
item.is_none(),
item.as_ref()
.map(|i| (std::cmp::Reverse(i.quality()), i.name(), i.amount())),
)
});
}
for (pos, item) in items.into_iter() {
if self.details_mode && !self.is_us && matches!(item, None) {
continue;
}