Organisms like fungi and algae switch to sexual mode just before the onset of adverse conditions because sexual reproduction would bring about variations into the organisms. This variation might help them to be able to survive in unfavorable conditions.