PARK CITY, Utah — By the hundreds they came — sorry, arrived — all of them jockeying for position — sorry, maneuvering for position — to get one of the Sundance Film Festival’s hardest tickets.

Let me start over.

Amid a festive, political-rally kind of a mood in Park City, with chirpy staffers handing out “VOTE WEINER” buttons, the documentary “Weiner” made its world premiere to tidal waves of laughter.

The movie amounts to the funniest funeral oration you’ve ever seen, as it buries longtime pubic official Carlos Danger, the disgraced former Brooklyn-Queens congressman who resigned his office amid one sexting scandal in 2011 and got 5 percent in the Democratic primary for the mayor’s race two years later after it became known that he had resumed his sexting.

Even though the film was made by a former Danger loyalist — ex-chief of staff Josh Kriegman — together with co-director Elyse Steinberg, the movie plays like a “Spinal Tap” of politics, complete with a hilarious scene of Danger, to a soundtrack of spy music, desperately sneaking through a McDonald’s and up a back stairway to avoid contact with Sydney Leathers, a sexting pal and aspiring porn star who was trying to meet him in person for the first time on the way to his concession speech on election night 2013.

“All this for a 23-year-old?” Leathers says to the cameras, unaware that Team Danger has given the elaborately planned episode the code name “Operation Pineapple.”

The Post is a co-star of the film (just send the check to 1211 Sixth Ave., guys), which features a dozen or so of our funniest front-page stories — in the trade, we call the cover the “wood” — as well as Danger’s end of a phone conversation with columnist Andrea Peyser.

“Let her get it out of her system,” is Danger’s reasoning about why he should do the interview — Meat the Press! — against the advice of his hapless publicist.

Initially planned as a supportive comeback doc, the Politico-meets-Penthouse film, which hits cinemas in May and Showtime in October, right before Election Day, instead features more absurd and inexcusable behavior than “Trainwreck.”

At the outset, Danger is promoting himself as a “fighter for the middle class.” (Cut to his swanky, $12,000-a-month Park Avenue South apartment, in which the kitchen alone could house a family of six.)

His hope is to portray himself as a policy guru who has learned his lesson and been honest about his mistakes.

As the news media start blasting out stories about “Carlos Danger” amid the 2013 mayoral race that Danger was winning, we check in on the deluge of jokes told by TV comics as well as the shellshocked mood inside Danger’s Fifth Avenue campaign office.

We are right there in the room with Weiner and his wife, Huma Abedin, a top aide to Hillary Clinton, immediately after the second group of quick pics of a Weiner who has misplaced his underpants hits the media.

Danger is all strategy smugness; his wife, trying not to betray any emotion while the cameras roll, stares daggers at him. When he finally, after many agonizing seconds, realizes her emotional temperature is about zero degrees Kelvin, he asks the filmmakers to step out of the room.

The movie makes it clear that both Dangers are utter phonies who place pursuit of power above all else. (One amusing moment features Abedin sweet-talking to a donor about the latter’s engagement on the phone, then hanging up and immediately switching to a hard-nosed discussion of the money.) Asked if Abedin was a key to his relaunch, Danger says, “She did. She was very eager to get her life back,” meaning get back in power.

Democratic Party staffers, we learn, worked for his campaign specifically because they wanted access to Abedin and hence Hillary. Danger is shown shamelessly playing for sympathy by inviting staff to his apartment for a damage-control meeting at which his baby crawls around in front of them, then literally wheeling the befuddled kid into a polling place on Election Day and standing the little one on a desk while preparing to vote for himself. The kid bursts into terrified sobs as photographers’ flashes go off.

The unstated implication is that everything in “Weiner” applies to the Clintons, only more so. When Danger reads an editorial defending him about all the things he didn’t do — didn’t rape anyone, didn’t sexually assault anyone, didn’t commit adultery, didn’t misuse his office, etc. — many of the allegations have credibly been made against Bill Clinton. (There is a minute or two of film considering news reports that Hillary might have demanded Abedin distance herself from Danger if she wanted to keep her job.)

Throughout the film, Danger displays an arrogance as swollen as his briefs, responding to a random detractor in a bakery who calls him a “scumbag” that “it takes one to know one,” then getting in a shouting match with the citizen. When his own polling expert tells him he has zero chance of victory and is bailing, Danger refuses to listen to reason and muses about saving himself via a “Bulworth” moment of unhinged hard-left appeals. He is seen chuckling at video of his disastrous, out-of-control interview with MSNBC host Lawrence O’Donnell, while a disbelieving Abedin asks, “Why are you laughing?” After his concession speech, Danger is photographed giving the finger to photographers.

Later, he has his only moment of true clarity in the film, when he says, “I can’t believe I gave the press the finger. I have this virtually unlimited ability to f- -k things up.” One of the filmmakers replies (in a line that drew huge laughs), “Why are you letting us film this?”

There’s even a brilliant cameo by Donald Trump, who is seen in a news clip saying, “We don’t want perverts elected in New York City. No perverts!”

“Weiner” has drama, laughs and surprises. It’s the full package.