You don't have to throw anything away (I used to be a medic in the Army, and have had to treat every kind of fungus you can imagine). Fill your bathtub halfway, put in half a cup of household bleach, mix the water with your hand to distribute the bleach in the water, then throw all of your shorts in the tub. Let them soak overnight. Then wash and dry them as normal, any fungus or bacteria will be removed.
If you live in a place where there is regular sunshine, dry your shorts on a clothesline after washing, the sun does a very good job of killing fungus and bacteria.