Confused about DPS

I am having trouble understanding how DPS is functioning. As an example, let’s say I have two weapons - a sword and a lance. The sword is a rare sword, level 56, with DPS for the weapon itself shown as 3456 (all numbers made up for illustrative purposes only). The lance is an epic lance, level 63, with DPS for the weapon itself shown as 7965. Yet, when I equip the rare sword, which is lower in level and lower in DPS than the lance, my total DPS in my stats is HIGHER than when I equip the epic lance, which is higher in level and showing higher in DPS!

Of course, the affixes on the two weapons are different, so maybe that’s the answer. But I even have an item that has epic affixes of +2 or +3, and yet another item of the same type with affixes of +1 will give me higher overall DPS.

How is this possible?

I don’t know anything about the inner workings of game mechanics (code, math, or whatever), so maybe this is easily answered. Or perhaps the answer is horribly complicated, and is best left unanswered. Or maybe I just don’t know enough to even ask the right questions. But any polite responses in layman’s terms would be appreciated.

the affixes make a huge difference, its probably something in there. the element and stats also matter, I currently have a chest piece with stonecold (makes frost dmg higher) I can find a higher dps then my weapon, but unless its frost it wont actually be higher. You can always change the ele of your weapon, but it could be something along those lines.