There are many impediments to ordination. The bar is very high, according to the canonical tradition and the Fathers. As always, in reality there are many exceptions to the rule -- exceptions on everything from staying a priest after divorce to even getting married after ordination. However, in the official texts it is required to have exhibited life-time obedience to the divine order of sexuality and marriage (which is an institution rooted in the divinely created order itself, only treated as a distinct sacrament quite late in Christian history, after this was settled in canon law).
So, the official canonical sources from all Churches except modern-day Antioch are very clear on the question. And, yes, merely having sex before or outside of marriage is listed as an impediment, as are other things.
The standards have less to do with personal holiness and more to do with standing within the community. Ordination is not conferred on someone as a private benefit but rather as an initiation to public leadership within a specific community. It's about the Body of Christ, not the individual. It's about public ministry, not private growth. So, the canonical tradition and Fathers are very concerned about public perception and preventing any cause for public scandal. A deviant private past has the potential to threathen one's public future. We see it happen to politicians and other community leaders all the time. The canons seek to avoid this kind of scandal, as it hurts the Church's witness and even in some cases her unity. So, again, the bar is high for the sake of Christ's Body, not as punishment to the individual. But specific Bishops can always make an exception, as they guard the Church's purity and unity.