Be intolerably sweet, pleasant and polite to them (if they give you the chance, of course). Address them as sir/madam. It will make them feel bad for being such bastards to you. I've worked part time in retail for 4 years now, so I guarantee this will work in 90% of cases. Even if they don't apolgise, it tends to make them feel sheepish.
As for the sexist customers, I suggest a response something along the lines of, 'I can assure you that despite my gender I am completely knowledgeable about the product in question. If however, you prefer the same assistance to be given to you in a male voice, I'll seek out a colleague for you right now'.
I almost wish I worked somewhere where sexist arses were commonplace, just so I could use that myself.
And don't let customers wreck your confidence. Remember 99.5% of them are complete retards just looking for some poor sod to vent the frustrations of the meaningless life upon.