Stacks are purely visual, if you have a stack of 5 red potions, you actually have 5 seperate red potions in the inventory list. If they are unsorted, and the first potion of the stack is used, the stack will travel to the position of the second potion.