Some fish can change their sex all the time
Bluebanded goby fish, about 2 to 2.5 inches long, are able to change their sex when it suits their position in social hierarchies.
“We can detect within minutes, via changes in behavior, when a fish begins the transition, and it generally takes one to two weeks to complete the transition from female to male,” Grober explained.
Sex-changing fish: Secret lives of bluebanded gobies – Light Years - CNN.com Blogs
For sex change in either direction, there seems to be one guiding social principle: If subordinate, be female. Because each group had only one dominant individual, each group ended up with only a single male.