As a mage, with Wynne in my party, I didn't have too much trouble with this level, although I got killed a couple of times until I figured out better tactics. I can see I'm going to have to use a different strategy with my rogue Dalish elf archer, though!
It doesn't matter if all the militia die. If you've got a mage with healing, you can heal some of them--Wynne was particularly good at this on my playthrough but only the mayor survived in the end. Still, it doesn't make a major difference to the story, so don't stress yourself out trying to keep any of them alive. If you find you're getting overwhelmed, let the militia tank as long as they can hold out while you're supporting them, and then when they're gone, start luring the enemy up to the area where the knights are.
As a rule, I give all my NPCs bows as their secondary weapon, even if they have no archery talents. This way, we can pepper an enemy with arrows and soften them up somewhat until they make it into melee range. So once the militia is all dead, draw your party back up the hill closer to the knights, give them any bows you may have in inventory, set them to hold position, then use one of your characters to go back down the hill and draw the attention of the enemy and lure them within range of the knights, who hit a hell of a lot harder than the militia. I think this would work especially well with a rogue who could attack at range from stealth and get a free sneak crit, but you've got to work with what you've got.