Terraria – What are the precise rules for inventory sorting feature in Terraria

terraria

With the new update a new button has appeared. It says "Sort inventory":

image description

When you click it, items in your items will be reordered and colored, presumably based on what type are they according to the algorithm:

image description

Items marked as favourite will be unaffected. However it's entirely unclear what order applies to items of the same type. I was hoping to sort all my potions by name. That's not what is applied, as you can see here:

image description

So what are the precise rules for sorting items, their colors and order of the items of the same type? This is a new feature, I'm sure other people are also curious how does it work…

Best Answer

The other answer is false. The items are sorted by type (i.e. melee weapon, ranged weapon, block etc.), and the colours do not correlate with the rarity. This can be seen in that the copper shortsword, with a white rarity, is light pink when sorted.