So… I’m having a bit of an issue. I’ve made an inventory system that has stacking and populates a UMG window, filling a scroll box with content from the inventory array… My issue is that the sorting of the items is based on when you pick them up, meaning that if you have two items picked up at different rates, then when you use or drop one it moves around… Let me explain with an example:
- Player picks up item: bandages
- Player picks up item: can of food
- Player picks up item: bandages
At this point the inventory displays:
Bandages (2)
Can of Food
If the player clicks on Bandages (2) and uses or drops one, the inventory then switches to this:
Can of Food
Bandages
I have been looking into sorting algorithms and stuff but I have absolutely no idea how to implement them. I even tried to just manually set the array index based on the item class, using a variable, but that didn’t work (guessing you can’t force multiple items ot have the same array index).
Does anyone have any idea how I would implement a sorting algorithm using blueprint? Ideally it would be alphabetical, but ANY sorting would be great - even if it was based on player pickup order, but once it was set it was maintained, etc.
I feel like it has to be easier than I am thinking - things like score boards and all that should be using this I guess? I dunno. Help