From 87ce17df8b0dedfd9fc8d0cc2f16a9c28c3e6f0b Mon Sep 17 00:00:00 2001 From: Gouvernathor <44340603+Gouvernathor@users.noreply.github.com> Date: Thu, 16 Nov 2023 02:17:25 +0100 Subject: [PATCH] Use inplace sort and generator expressions --- game/scripts/interface/inventory.rpy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/game/scripts/interface/inventory.rpy b/game/scripts/interface/inventory.rpy index 9974d28b..d22f265c 100644 --- a/game/scripts/interface/inventory.rpy +++ b/game/scripts/interface/inventory.rpy @@ -1,17 +1,17 @@ init python: def inventory_sortfilter(item, sortby="A-z", filtering=None): if filtering == "Owned": - item = [x for x in item if x.owned > 0] + item = (x for x in item if x.owned > 0) # Always sort alphabetically first. item = sorted(item, key=lambda x: natsort_key(x.name)) if sortby == "z-A": - item = sorted(item, key=lambda x: natsort_key(x.name), reverse=True) + item.sort(key=lambda x: natsort_key(x.name), reverse=True) elif current_sorting == "Available": - item = sorted(item, key=lambda x: x.owned is True, reverse=True) + item.sort(key=lambda x: x.owned is True, reverse=True) elif current_sorting == "Unavailable": - item = sorted(item, key=lambda x: x.owned is False) + item.sort(key=lambda x: x.owned is False) return item