How is mixed army formation determined

So while while back there was a change that made heavy infantry stand infront of light infantry when grouped together

How is this done??

Im trying to change the order that flamethrowers stand in formation but dont know where to start??