How to improve this sorting structure function (issue with duplicated name)?

Hello,

Like many people, I’ve been building an inventory system. Like many people (for what I’ve seen), I have an issue trying to sort my inventory by ascending (or descending name) name.

So far, this is what I got, which used to work fine:

But as soon as I have duplicated names, it falls appart.
For instance, if I have two “sword” with different durability, the first sword will be added to the map under the key “sword”.
Second “sword” coming with a different durability, it will also be added to the map under the key “sword”, which is already present in the map, so it will erase the first “sword” occurrence (and its durability). And then, instead of having two “sword”, I end up by having just one occurrence in the map.

But I don’t see what else I could do to sort an inventory. Any idea?

Map keys are unique. Try just sorting the string array?