A federal judge upheld the city’s firing of a Bronx kindergarten teacher who allegedly incited a mini-riot by standing idle as a gang of 5-year-olds pummeled a classmate.

Federal Judge Jed Rakoff dismissed former PS 396 teacher Sarrit Segal’s suit seeking to overturn her ouster. She claimed the firing was based on an incomplete and biased probe of the March 5, 2004, incident.

But Rakoff said Segal jumped the gun by filing the suit, complaining that she did not file an administrative appeal with the Department of Education.

“The DOE offered her an opportunity to clear her name, and even avoid termination, by pursuing an administrative appeal,” Rakoff said.

The teachers union already had prepared to file an appeal on the second-year probationary teacher’s behalf, but Segal declined the offer.