A prison riot that caused almost £3m in damage and left one inmate dead was sparked by a row over sandwiches, Lincoln Crown Court heard.
Damage put at £2.75m was caused during the 2002 riot
The destruction at Lincoln Prison in October 2002 was the worst disturbance at a British jail for 11 years.
Prisoners seized control of the jail for eight hours during the riot.
Twenty-one inmates received sentences for prison mutiny, assault and unlawful wounding, and violent disorder, getting a total of 97 years in prison.
The extent of the disorder emerged on Friday as the last of the inmates involved was sentenced.
The background to the riot - including anger over the loss of hot meals from the jail canteen's lunchtime menu - was revealed in court.
Earlier hearings could not be reported until the end of all proceedings, which wrapped up on Friday.
Nine-year sentences were given to:
- Alan Brown, 30, from Nottingham
- Gavin Collins, 24, from Mansfield
- Michael Westwood, 23, from Birmingham
- Benjamin Daws, 24, from Nottingham
- John Thomas
Lambert, 23, from Sutton on Sea, Lincs
- Lee McGrath, 32, from Louth, Lincs
Sex offenders were forced to barricade themselves in their cells as the mob ran wild after prison officers fled the building.
The authorities first lost control of the Victorian-built Category B jail after prisoners overpowered a guard and stole his keys to cells.
It took a year to get the jail back in full working order
They released fellow inmates and the prison was overrun, flooded, looted and wrecked.
Gordon Aspden, prosecuting, told earlier hearings how the riot was planned by a group being held on the jail's A Wing.
Some sex-offenders feigned death as the rioters exploded oxygen cylinders in an attempt to blow open their cell doors.
Mr Aspden said: "There was discontent about changes to the prison menu and the introduction of sandwiches at lunchtime.
"A group of ringleaders were responsible for starting the trouble, but once the mutiny was in progress other inmates took the opportunity to join in.
"It was sheer lawlessness. There were numerous assaults on other prisoners, and everything that came to hand was damaged or destroyed.
"Absolutely no mercy was shown. For over eight hours the prison was in the hands of the inmates. It was anarchy."
'Anarchy and mayhem'
Some 168 prison riot officers brought from jails up to 150 miles away took over again at the jail at 0400 BST on 24 October.
One prisoner died after taking an overdose of drugs looted from the pharmacy, while another 35 people needed hospital treatment.
Judge Heath, who passed the last of the sentences on Friday, added: "There was anarchy and mayhem. The prison was in the hands of the prisoners for about eight hours."
The judge said the mayhem was the worst in England since the riot at HM Strangeways, Manchester, in 1990.