Short answer: it's messy, and probably no answer will satisfy everyone.
I'm only going to consider sex (I'm not going to mess with "gender") in humans.
- It's reasonable to consider sex as multidimensional rather than one-dimensional; see the various definitions listed below. The same individual could have different karyotypic, morphological, and endocrinological "sex".
- Some but not all of the definitions refer to continuous scales, i.e. if you pick one of the continuous measures below (Quigley scale, circulating testosterone level) you can probably find at least one individual in any not-too-narrow interval on that scale.
- It's reasonable to say that many of the continuous measures below are bimodal, i.e. in some random sample of humans there are more people close to 1 or to 6/7 than in the 2-5 range on the Quigley scale; similarly, there would be more people in the ranges of 10-30 ng/dl or 200-500 ng/dl in their testosterone than in between.
Here are some of the possible definitions of sex, drawing on the Wikipedia article mentioned in the comments:
- karyotype (chromosal type): this is discrete (XY, XX, XYY, XO, XXY, ...) but not necessarily easy to split into "male" vs "female" except on the basis of what the phenotype (morphology, endocrinology, etc.) looks like. Would "male" mean "has a Y chromosome" (XY, XYY, XXYY)? or "has only one X chromosome" (XY, XYY, X0)? Would female mean "has no Y chromosome" (X0, XX) or "has 2 X chromosomes" (XX, XXY, XXYY)? Non-standard sex karyotypes are rare: e.g X0 1 in 3000 live births, XXY [Klinefelter's syndrome] 1 in 1000 live births; XYY 1 in 1000 live births; XXYY 1 in 20,000 live births (Jarzembowski, J.A. “Sex Chromosome Abnormalities.” In Pathobiology of Human Disease, 185. Elsevier, 2014. https://doi.org/10.1016/B978-0-12-386456-7.01505-7 ; https://rarediseases.org/rare-diseases/xyy-syndrome/)
Below the level of the chromosome, there's lots of genetic and environmental variation that can change the phenotype (e.g. here)
- morphology (gonads or internal/external genitalia): the Quigley scale referenced in comments above is one way to describe this variation. The Quigley scale could be used to classify phenotype in cases of
(the section on intersex conditions in the Wikipedia article on sexual differentiation links to these among others)
(these are cartoons of external genitalia, in case that's not obvious)
Intermediate morphology can occur in the gonads as well as in the genitalia or internal organs; according to MedLine Plus (US National Library of Medicine), people with "true gonadal intersex" have "[both] ovarian and testicular tissue ... in the same gonad (an ovotestis), or the person might have 1 ovary and 1 testis".
- endocrinology (levels of various circulating hormones): researchers most typically consider testosterone (e.g. in this article). This article reports on total serum testosterone in a US health survey. The distribution is indeed bimodal (there's a peak around 10-30 ng/dL for women and 250-600 ng/dL for men), but this article only reports the 10th and 90 percentiles; there could certainly be someone with a circulating testosterone level right in the middle. It's also important to note that a person's phenotype/morphology (musculature etc. as well as gonadal morphology) is not necessarily closely related to their level of circulating testosterone, depending on whether they are androgen sensitive or insensitive ...
In light of recent (August 2024) Olympic boxing controversies, here's some more data on circulating testosterone distributions from Clark et al (2019)
top solid line for each column is the weighted 95% confidence interval for normal men and women, solid line for each study is 95% confidence interval, dotted line is absolute range. Blank spacer line below a study reference indicates an additional subset for that study
[PCOS = polycystic ovary syndrome, 5ARD2 = 5-alpha reductase deficiency, PAIS-CAIS = partial/complete androgen insensitivity syndrome]
So ... the answer to your specific question about being able to classify people based on gonad type is that although it's rare, people with true gonadal intersex as defined above could not be classified as either (exclusively) male or female on the basis of their gonads. Furthermore, it's not obvious which of the many criteria (karyotype, internal/external morphology, endocrinology) would be the "correct" way to define sex in a particular scenario.
Clark, Richard V., Jeffrey A. Wald, Ronald S. Swerdloff, Christina Wang, Frederick C. W. Wu, Larry D. Bowers, and Alvin M. Matsumoto. “Large Divergence in Testosterone Concentrations between Men and Women: Frame of Reference for Elite Athletes in Sex-Specific Competition in Sports, a Narrative Review.” Clinical Endocrinology 90, no. 1 (January 2019): 15–22. https://doi.org/10.1111/cen.13840.