Hang the top of the dryer cord on a hook hanging from your wall or a doorknob and keep a piece of duct tape handy. Some blow dryers come with convenient hang loops for this purpose. Untwist the cord slowly from the top on down and then tape the bottom to the wall or door. Allow it to sit overnight or longer so that it lays straight again.
Take care in how you handle the dryer when you're drying your hair. Check the cord periodically to make sure you're not twisting it while plugged in because that causes the cord to twist again. You have to be more conscious of this if you want to keep your hair dryer cord straight over time.
Wrap up the dryer cord immediately after each use, but take special care with it. Oftentimes you might just toss the dryer in the sink after finishing when in a rush, but this can cause coiling over time. Start at the base close to the bottom of the dryer and wrap the cord carefully around a cardboard toilet paper roll or a cord keeper with "teeth," which you can find at home goods stores.
Fanfold the cord as another option. Trace your fingers down the cord carefully as you fold it up then down again until you're grasping it in your fist. Wrap the cord with an unraveled toilet paper roll or tight cord keeper.