We know famously that upon Leah becoming pregnant with her seventh child, she realized that if she were to give birth to a boy it would mean that out of the twelve tribes, she would have given birth to seven, the two maidservants Bilha and Zilpa each had two, and this would mean that her sister Rochel would be deemed inferior to even their handmaids in the formulation of the twelve tribe as she would be responsible for giving birth to only one of the tribes.

Such was her distress for her sister that she davened that the gender of the baby be changed. [Rashi][1] on the pasuk in [Bereishis 30:21][2] tell us:

>**דינה.** פֵּרְשׁוּ רַבּוֹתֵינוּ שֶׁדָּנָה לֵאָה דִּין בְּעַצְמָהּ, אִם זֶה זָכָר לֹא תְהֵא רָחֵל אֲחוֹתִי כְּאַחַת הַשְּׁפָחוֹת, וְהִתְפַּלְּלָה עָלָיו וְנֶהְפַּךְ לִנְקֵבָה (ברכות ס')
>
>***DINAH (Judgment)** — Our Rabbis explained, that Leah set herself up as judge (דנה) against herself saying: “If this be a son, my sister Rachel cannot be even the equal of any of the handmaids”. She, therefore, offered prayer regarding it, and its sex was changed ([Berachos 60a][3]).*

The [Targum Yonasan 30:21][4] goes one step further further and says that the actual embryos were switched. So Yosef was moved into the womb of Rochel, and Dina into the womb of Leah.

In keeping with this idea, I once heard a vort that as a result of this switch, despite being born as the individuals they were, they maintained a semblance of what their initial gender would have been, i.e. Yosef carried some female traits which accounts for his preoccupation with his hair etc. (see [Bereishis Rabba 84:7][5]), whilst Dina maintained some male leanings which is why she was emboldened to go out on her own ([Bereishis 34:1][6]).

Does anyone know the source for such an idea?


  [1]: https://www.sefaria.org/Genesis.30.21?lang=bi&with=Rashi&lang2=en
  [2]: https://www.sefaria.org/Genesis.30.21?lang=bi&with=all&lang2=en
  [3]: https://www.sefaria.org/Berakhot.60a.12?lang=bi&with=all&lang2=en
  [4]: https://www.sefaria.org/Genesis.30.21?lang=bi&with=Targum%20Jonathan%20on%20Genesis&lang2=he
  [5]: https://www.sefaria.org/Bereishit_Rabbah.84.7?lang=bi&with=all&lang2=en
  [6]: https://www.sefaria.org/Genesis.34.1?lang=bi&with=all&lang2=en