Sex is based on your physical genitalia, and indirectly your genes. Gender is based on your self image and your behavior. The two are not the same.
And this demonstrates the issue I was raising in the beginning. For the none CD/TS/TG community, sex does equal gender. But for the rest of us it does not. We see that though sex is an either or condition, gender is not. Gender may be a continuum, or it may be an n-dimensional construct, but it most definitely not limited to two, polar genders.
In his book, "The Essential Difference: The Truth about the Male and Female Brain", Simon Baron-Cohen makes it clear that instead of male and females brains, there are male and female cognitive patterns that are not solely found in genetic males and females, respectively.
Rather, both men and women, genetically, have a combination of male and female mental attributes. What is true is that most men tend toward male patterns of thought, while most women tend towards female patterns of thought. But this distribution of maleness and femaleness for both sexes follows a bell curve distribution.
Therefore, a man can have a female brain, while a woman can have a male brain. Think sissy and tomboy, respectively.
And this discussion does not even touch upon sexual orientation which is another matter altogether.