Imagine you have a house, this is your array. In your house there are rooms where you could store things. Rooms are in this case your X -Axis. Of course you could throw all your clothes on the floor of your room, but some of us decide to sort them. Thats why you need a wandrobe in your room. This is your Y-Axis. Now some kind of people (expecially women) are still not happy with just throwing all their clothes in the wandrobe. That's why they use drawers to seperate the underwear from the socks and so on. The drawers represent the Z-Axis.
House -> Array
Room -> X
Wandrobe -> Y
Drawers -> Z
I don't really understand what you're trying to do. But I can tell you what you're doing right now: You have a lot of underwear and to alocate them you write down in which room, which wandrobe and which drawer your underwear is right now. Afterwards you try to sort your underwear by the kind of drawer they're in. I think what you are really looking for is to sort them by the wandrobe they are in.
(it's also kinda strange that you say you have 6 rooms and with 6 wandrobes each but there's just a 5 * 6 matrix.