The relative ranking of castes can vary across regions and localities and depends on a number of factors including control over land, wealth, and political power. Castes have often tried to 'upgrade' themselves (a process sociologists refer to as Sanskritization), and sometimes get 'downgraded'. A revealing excerpt from Upinder Singh's Ancient India: Culture Of Contradictions.
Devdutt Pattanaik, who has simplified the ancient Indian scriptures for millions of readers, highlights what our scriptures have to say about homosexuals and transgenders.