When was sex invented?

when evolution found that mytosis was no longer the most efficiant way to reproduce