'Unity/C# - Sorting list of classes by outside variable
I want to sort my players inventory by an outside value, but my setup is as such:
List<ItemHolder> inventory;
class ItemHolder() { int itemID, int itemQuantity }
Then for my item database I have:
List<Item> itemDB;
class Item() { string itemName, int itemValue } // along with other stuff
The inventory is made up of any amount of ItemHolder classes, and my itemDB list made up of possibly hundreds of Item ones
I need to sort my inventory by comparing with an outside factor (itemDB[itemID].value), but after googling I still have no idea how to do this kind of thing. I've seen the Sort() and Linq OrderBy() pop up but as of yet cannot find any applicable to using outside variables.
Could anyone point me in the right direction?
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
