Some of you might know the menu in final fantasy where u can pick and change positions of the items, and especially the SORT button in the items section, which priorities and fixes all the items in a tidy way, so if you have potions/hi-potions, they are put at the top when u hit sort, if you don't have, they are invisible and some other items takes its place instead.

I don't need any code at all (maybe some examples would help ofc), I just need some ideas, how I could do this in a efficent way ie how the function could look like, how I should store the items, how I should store the positions of the items in the menu or how I should kind of give it some sort of prioritising function like the SORT button which sorts all your items in your bag.

What I have done so far is the menu in a while loop and my items are done with var potion = 0; (0 potions atm) I have also gave it a static position for the potion in the menu which is visible when the while loop is active and I have a potion, when potion is 0 it's removed automaticly next frame because of the while loop, but as I said I need some ideas on the way to make a scrolling menu with positions for the items, also to pick and replace another items position manually.

Thanks in advance and i'm in school right now so i'm writing this quite got a lesson in 5 mins so sorry if my grammar is not correct.

Picture from FF5 (example):