Hmm. Would there be interest in me making this function smarter, then?
Sure! Just make sure it is not worse in other respects (after it is tested and improved, etc.), because it is also used for generating equipments for aliens. E.g. it should be as random as the one currently in game, or the alien teams will become boring. Your description suggests you think about someting less random, so perhaps split it off for the initial equipment? But newbies deserve a surprise from time to time, too, e.g. dual-wielded pistols for one of their initial soldiers.
A way for keeping the randomness and other minor tweaks (e.g. that Assault Rifle rarely appears with an SMG, or primary and secondary tachyon weapons for the same alien) intact is to exchange the skills between soldiers after the weapons are assigned. But this is not easy to code...
By then, everyone should have their hands full.
A bit boring, at least for aliens, everybody gets a primary weapon...
It then passes out ammo corresponding to their equipment, put into the fastest-accessible places (belt, holster).
A problem here, because you won't fit a sidarm into the holster if there is already ammo, and no knife or plasma blade into the belt if the ammo is in the most obvious spot there... I'm also not sure if the XCom 1 setup that reloading takes constant time is not a good idea (nobody answered on the IRC two times I asked about that...)
Stopping when everyone has a secondary weapon.
Again a bit boring, isn't a guy with a pistol and a grenade a valid setup for some maps. And isn't such an alien a nasty surprise?
It lastly puts armor on everyone, in order of weapon range (those with the shortest-range weapons get the best armor).
Nice idea, I didn't think of that.
Anyway, good luck, I guess your code will be better at least for human soldiers and I'm curious how you will do that and I will surely learn from that...