Complex Inventory help?

hey guys

i have been trying different ways to create an inventory system both through object and array based inventory, one problem i’ve run into is how to make a stackable item?

some items will take up a inventory slot but other i will tag with variable “stackable=true;” which should make them stack up on one slot
Example ( sword,sword,metal(x3),scrap,scrap)

while object/array may look like
sword,sword,metal,scrap,metal,metal,scrap

something like that, how would one achieve such effect?
any suggestions on an easier way?