Editor's note: John Avlon, a CNN contributor and senior columnist and executive editor of The Daily Beast, is the author of "Independent Nation" and "Wingnuts." He won the National Society of Newspaper Columnists' award for best online column in 2012.
(CNN) -- Twelve years ago, New York City taught the nation about resilience in the face of a massive attack.
On Tuesday, New York again taught the nation that character counts.
There is, of course, no comparison between the horror of 9/11 and a mayoral primary in America's largest city. But while the shadow of the twin towers still hangs over the hearts of many in New York, the persistence of daily life remains a quiet sign of defiance.
This year, city politics seemed determined to hit a new low rather than aspire to new heights. A series of scandal-scarred candidates sucked up the oxygen amid an otherwise forgettable field. And for a while, Anthony Weiner and Eliot Spitzer seemed likely to win their respective races on the strength of name ID and notoriety.
If successful, their candidacies could have compounded the cynicism that surrounds politics in an era where too few leaders feel the obligation to hold themselves to a higher standard.
But when it was discovered that Weiner had been a recidivist sexter -- under the quintessentially creepy nom de guerre "Carlos Danger" -- something heartening happened: Common sense kicked in.
Weiner plummeted from first to fourth in the Democratic primary polls, with much of his support shifting to the aggressively progressive Public Advocate Bill De Blasio, who rose to pole position aided by powerful ads featuring his biracial son, Dante de Blasio, and a campaign theme focusing on inequality.
Likewise, Spitzer's last-minute entrance into the obscure city comptroller's race initially injected that campaign with a shot of adrenaline. The former state attorney general and governor had derailed a meteoric rise with ill-advised dalliances with hookers during a stormy tenure in Albany. Instant infamy was followed by a long slog for redemption, punctuated by a brief tenure as a cable news host on CNN and Current TV.
But the brilliant, ambitious Spitzer was always aiming for a return to political power, and he saw the comptroller's race as a means to that end, threatening to bigfoot the otherwise pedestrian campaign of mild-mannered policy wonk and career politician Scott Stringer. But the self-funded Spitzer was ultimately denied victory, an outcome that largely represented more of a rejection of Spitzer than an endorsement of Stringer.
On the Republican side of the aisle -- in a far less prominent race -- a self-made billionaire grocery magnate named John Catsimatidis essentially tried to buy the GOP nomination, encouraged by a cadre of consultants and a handful of high-profile endorsees, many of whom were persuaded to support the man at least in part because of his financial largess.
A barrage of negative ads directed at his opponent Joe Lhota -- a Giuliani administration deputy mayor during 9/11 (whom I served alongside) and chairman of the Metropolitan Transportation Authority during Hurricane Sandy -- failed. In a political world where big money often drives outcomes, this was one campaign where wealth didn't determine the winner. That's a win for representative democracy.
There is a final hopeful note in this primary election, 12 years after 9/11. In the past it has always been a cynical article of faith that winning campaigns were cobbled together by ethnic algebra. But this year, New York voters sent the clear, hopeful message that identity politics would not drive their decisions.
The African-American candidate, Bill Thompson, did not win the black vote. The openly gay City Council Speaker Christine Quinn did not win the lesbian, gay, bisexual and transgender vote or the female vote. That represents real progress and political evolution toward a more perfect union -- and that is the deeper purpose of our politics.
Twelve years after 9/11, voter participation still isn't what it should be -- turnout is low in closed partisan primaries, and that represents a creeping complacency where openness and civic energy should be an obligation.
But in rejecting the sociopathic circus in favor of more sober candidates who tried to build coalitions across old dividing lines, New Yorkers sent the message that substance can beat slick self-promotion.
Simply put, character counts. And for that timely reminder, it is worth saying again -- thank you New York.
The opinions expressed in this commentary are solely those of John Avlon.