Salamah bin Kulayb (may Allah have mercy on him) said that Jabir bin Zayd (may Allah have mercy on him) was asked about the inheritance of a hermaphrodite, and he said: He should stand and urinate towards a wall. If the urine hits the wall, he is a boy, and if it flows between his thighs, she is a girl.
A hadith with a connected chain (musnad) has been narrated on this, with a weak chain.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الفرائض / 12517