The main rule of organization is to have a place for everything and keep everything in its place. Space in medicine cabinets is generally pretty limited, so keep it to medications only. This means making a plan to stash toiletries under the sink or in other shelves or cabinets. Once you've decided how to categorize your boxes and bottles, now it's time to decide how to store them. You can go old school and simply line them up on the shelves, but that's not always the most convenient way to access things. Bottles get turned around or hidden behind others, so you end up rifling through in a hurry and churning it back into its same former mess.
In the age of Martha Stewart, there are containers that pretty much fit any scenario, and medicine cabinets are no exception. Most medicine cabinets are only 3-to-4 inches deep, so keep this in mind while shopping for containers. A great option is to find some clear acrylic containers that fit narrow medicine cabinet shelves and group items together in several of those. That way, when you need something, you can simply pull down the container or caddy and take it with you. If you're a big discount club shopper and like to buy large sizes of things like aspirin and mouthwash, it's a good idea to invest in some smaller size containers that will fit in a medicine cabinet to keep a supply of these things on hand and then store the large containers in a pantry or cabinet. Be sure to clearly label any containers that aren't original to the medication.