Mark Sanford they are not.

Anthony Weiner and Eliot Spitzer, both disgraced politicians who resigned from office amid revelations of their extramarital escapades, failed in their political comeback bids Tuesday night. Spitzer lost the New York City comptroller's primary by a slim 4-point margin, while Weiner finished a distant fifth in the Democratic primary of the mayoral race.

For a time, polls showed the two leading their respective races. Yet in the end, both fell short, in the process offering a few lessons about disgraced pols with dreams of redemption.

The early success of the two showed that voters don't view sex scandals alone as a disqualifying factor. South Carolina Rep. Mark Sanford (R) proved the same in May when he won a special House election four years after it was revealed that he had snuck out of the state to visit a secret mistress in South America.

However, not all sex scandals are created equal.

All three men cheated, to varying degrees, on their wives. Weiner sent lewd images to women, Spitzer frequented prostitutes, and Sanford had his Argentinian affair.

While Sanford divorced his wife and is engaged to his mistress, on the campaign trail he portrayed himself as a humbled family man. Displeased with his cheating, voter were nevertheless willing to accept his purported reformation.

Prostitutes and nude selfies, by contrast, are more bizarre and therefore harder for voters to fathom. And Sanford, unlike Weiner and Spitzer, "seemed genuinely sorry," for his actions, said Politico's Maggie Haberman, making him more likable.

"The so-called 'dance of the honest man' is necessary — even if you have to fake it," she wrote.

Further, Weiner and Spitzer's campaigns were largely done in by the circumstances of their individual races.

Sanford, a former governor and congressman, was running against a Democrat in a deep-red district. In 2012, Republican Tim Scott won re-election in the congressional district by a nearly 27-point margin. (Scott was subsequently appointed to fill a vacant U.S. Senate seat.)

Weiner and Spitzer, on the other hand, faced off against other Democrats in a blue city, giving voters a choice between multiple candidates with similar ideologies. In Weiner's case, he shared a ballot with eight other candidates, four of them well-known elected officials.

Weiner also, as you may have heard, was caught sexting random ladies on the Internet even after resigning from Congress for sexting random ladies on the internet. Once he was trapped in a semantic pickle about whether he stopped sexting when he said he did, his once-rising campaign flatlined. Last month, a Siena College poll found that 80 percent of New Yorkers viewed Weiner unfavorably, making him the most unpopular politician they had ever polled.

"We had the best ideas," Weiner said in his concession speech, after running through a McDonald's to avoid Sydney Leathers, the sexting partner who exposed his latest philandering. "Sadly, I was an imperfect messenger," he added, before flipping off a reporter.

Spitzer's case was different. He had an enormous lead with one month to go, and he did not mislead voters about his behavior post-resignation. He even went up with an ad in which he acknowledged, "I failed — big time."

His downfall was more the result of hard-hitting opposition than self-immolation.

Spitzer's opponent, Manhattan Borough President Scott Stringer, relentlessly attacked him in ads as a "colossal failure," blasting not only his sexual impropriety, but his financial stewardship as well.

"Why would we ever go back?" one ad asked. "We already know how this story ends."

Stringer also won the endorsements of New York City's three major daily newspapers, after which his campaign erased Spitzer's lead. The New York Times, in throwing its weight behind Stringer, lauded Spitzer's "intellect," but said he had entered the race "seemingly for no reason except to thrust himself back into the limelight."

"We don't need another celebrity office seeker," the paper added.

So to future disgraced politicians attempting comebacks: Don't get caught repeatedly lying about your sexploits, and pick a race where you have a huge built-in political advantage.

Or, you know, keep your damn pants on in the first place.