On his first day in one of South Africa's notorious Western Cape prisons, 16-year-old Ivor Swartz knew his only choice for survival was to join one of the brutal prison gangs that ruled the correctional centres. "If I didn't join a gang very quickly, there's a good chance I would have been raped in the first few days," said Ivor. The choice he made would define the rest of his time in jail.

Ivor grew up in Grabouw, a small, quiet town in Western Cape, South Africa, known for growing apples and not much else. He had an upbringing typical of his area; poor, rife with street-violence and fatherless homes. Ivor's father died when he was young so his older brother, Dion, took charge of the house. He was a tough man made hard by life in Grabouw. He was abusive to his family and drank heavily. "If I tell you he was monster, that's a real understatement" said Ivor.

Read more South Africa's sex workers are lured by cash but face lethal risks beyond disease and addiction

At 14 and unwilling to live under his brother's rule, Ivor took to the streets. There, he befriended a group of young men under similar circumstances to his; from divorced families, broken homes and runaways.

"The way we formed a group was simply because we shared our suffering. Our suffering pushed us to the street and brought us together," he said.

The group shared their first drinks, first drugs, and even first burglary together. At 16 Ivor also became a father for the first time.

Together the group assaulted people on the streets of Cape Town, taking their phones and wallets. They stole from people's homes and smashed car windows, taking whatever may be valuable.

With extreme overcrowding, sparse budget, and new prisoners pouring in every day, it seems prison warders have little to do but keep the prisoners contained and allow, to a degree, the running of the gang system.

Ivor's gang shared a gun between them. It was a 38 calibre handgun that had been tossed on a fire by a previous owner on the run from the police. Someone had taped bright red duct tape to repair the handle: "I don't know why we chose red because that made it look fake!" says Ivor, laughing and shaking his head. "But that gave us a bit of power to rob people on the street."

One fateful night, Ivor and two friends entered a house while the home-owner was asleep inside. They held her at gun-point and took her TV and other belongings. Later that year, the surviving home-owner recognised Ivor in a line-up and he was arrested for the break-in. His fingerprints were found at that scene and later linked to another case of robbery in the area. Ivor was collectively sentenced to six-and-a-half years in prison for the burglary charges. From ages 16 to 21 he would be behind bars.

Ivor quickly associated with a gang, knowing full well it was his best chance for survival. He was alone, having left his family; and without access to money, joining a gang meant he had access to food, a bed and social interaction to pass the time.

There are around 240 prisons in South Africa, 42 of those are in the Western Cape housing nearly 30,000 prisoners. But these statistics don't take into account criminals who were serving other kinds of sentences or have been released on bail. Ivor estimates around 80% of those prisoners in the Western Cape are gang members.

There are hand signals for each gang; 26 is two thumbs up, 27 is thumbs up and index fingers pointing toward the horizon and 28 is thumbs up, index and middle finger together and pointing forward.

In these prisons there are three well-known gangs; 26s, 27s and 28s. Collectively known as the numbers gangs, they are notorious around the world. In stories, the history of the gangs goes back to 1812. "We don't know if that is true but that's the history and each gang must know their history" says Ivor. A history which changes depending on who speaks of it.

The gangs are ranked much like the South African military service, from generals to privates, and run like a rookie military too. It's rumoured the three gangs all originate from bands of fugitives that plagued late 19th and early 20th-century Johannesburg.

The numbers gangs were chiefly inspired by one bandit in particular, Nongoloza Mathebula, and his band of quasi-military outlaws. Some might remember him as an African version of Robin Hood, taking from the victors of South Africa's colonial order and giving to the downtrodden victims.

Read more South Africa humours the US for aid money by paying lip service to human trafficking

The sole impetus of a 26 gang member is money and getting it by any means possible. As Ivor had spent much of his youth on the street hustling, the ideals, social order and code of conduct resonated. Violence was secondary to the goal of collecting cash so Ivor quickly associated with the 26s – known as the least brutal of the three gangs. The 26 gang has a strict membership policy and doesn't allow anyone to join their gang who has been raped, snitched on anyone, or has any physical defects. A 26 candidate should be in good health, willing and able to fight for one's camp.

28s, on the other hand, show no discrimination; a contributing factor to why it's the largest known prison gang in South Africa. A 27s focus is drawing blood, particularly from a prison warder, a sure way to climb the ranks as a 27 member. Stabbings of prison warders are reported frequently, yet subtly, in South African news. Little is said about what encourages the attacks; supporting Ivor's belief that the prison officials hope to conceal the numbers gangs' true reign on the prisons.

There are two lines of the 28s – those that choose to climb the ranks by sodomising other prisoners and those who choose to stab warders. The 26s and 28s don't get along and their animosity frequently descends into violence.

There are hand signals for each gang; 26 is two thumbs up, 27 is thumbs up and index fingers pointing toward the horizon and 28 is thumbs up, index and middle finger together and pointing forward. There is a slight distinction in the two signs for the sections of the 28's. The 'sodomy 28's' hold their index and middle fingers together when holding up their signs and the blood 28's hold them apart.

The numbers gang system is an intricate social structure with its own language, codes of conduct and rules every member must adhere to. However, the system works only in the construct of prison. A high-ranking 27 from Pollsmoor Prison, inked to the ears, means nothing on the streets of Cape Town.

It doesn't take long to get the picture that the numbers gangs run the prison. Uncontrollable prisoners make for very bad PR and the easiest way to maintain an illusion of control is to allow gang members to quietly maintain order. Ivor believes fighting against the gang system in prison will only lead to violent uproar and protest from the prisoners. With extreme overcrowding, sparse budget, and new prisoners pouring in every day, it seems prison warders have little to do but keep the prisoners contained and allow, to a degree, the running of the gang system.

Read more South Africa's staggering crime epidemic: 19,000 murders and 39,000 rapes in one year

The golden rule in prison? The fastest live the longest. "If you don't stab first, you will get stabbed. That's how we lived, every day," says Ivor. The fight between will power and social pressure is an age-old battle and Ivor wasn't always on the right side.

Ivor was released in December 2005 after serving his time. "Not a single minute of solitary confinement was as lonely and scary as that first day out." Ivor recalls.

Sadly, not many prisoners make it past two months of being free. "Your gang becomes your family, what you live for," says Ivor. Prisoners are so conditioned by the prison system, into their gang network and way of life that the outside world makes little sense anymore and their freedom becomes a new cage.

"Life is better in prison than on the outside, especially if you belong to a gang" says Ivor. "You're respected, guaranteed a bed, blankets, food and a sense of community. Those things don't come easily when you're on your own on the outside."

Ivor has been out of prison for 11 years. He is now a youth pastor working at St Paul's United Church in Johannesburg. He thoroughly enjoys his work and is excited about his prospects at the church. "The church saw value in me and spoke worth into my life." He admits he never pictured himself doing what he does, but now that he's found God and helping to mould young minds, Ivor wouldn't have it any other way.

Skye Forrester is a contributor to a number of print and online publications spanning sectors including natural health, social and political commentary, as well as food and fashion trends. Follow her on Twitter @qwertysmirks