Items sort button

Hello, i got problem. How to sort items after clicking a button? I mean i got few buttons and when i click one of them i want hide all of my items except potions.
I guess i should take target somehow from second hud element- “Inventory”. Any ideas?

Youtube to the rescue!