I'm making an RPG game with an unlockable slot based inventory system. At Level 1 there are 8 slots available, at Level 5 there are 16.
In my GameData array (which controls all the player modified variables for save files) I store the inventory data in the Z axis, specifically (0,3,1-16). (0,3,0) is where I store the player's currency variable.
Each slot, 1-16, holds an ID number that corresponds with an item from a different array, ItemDB. If the ID is >=0, then the item slot is filled with an item. If the ID is -1, the item slot is empty. If the ID is -2, the item slot is locked and needs an upgrade to be unlocked.
How do I auto-sort these items in a 3D array for just that small Z-axis segment from ItemID to Empty to Locked? I found some good examples for a 1D array, but nothing for a 3D array. Basically, this:
0,3,1 : 12
0,3,2 : 8
0,3,3 : -1
0,3,4 : 3
0,3,5 : -1
0,3,6 : 3
0,3,7 : 5
0,3,8 : -1
0,3,9 : -2
0,3,10 : -2
0,3,11 : -2
0,3,12 : -2
0,3,13 : -2
0,3,14 : -2
0,3,15 : -2
0,3,16 : -2
0,3,1 : 3
0,3,2 : 3
0,3,3 : 5
0,3,4 : 8
0,3,5 : 12
0,3,6 : -1
0,3,7 : -1
0,3,8 : -1
0,3,9 : -2
0,3,10 : -2
0,3,11 : -2
0,3,12 : -2
0,3,13 : -2
0,3,14 : -2
0,3,15 : -2
0,3,16 : -2