Damage reduction and damage resistance: how to calculate?

Assume a character has both damage reduction and damage resistance vs an incoming attack.

One example of damage reduction is the Heavy Armor Master feat:

While you are wearing heavy armor, bludgeoning, piercing, and slashing damage that you take from non magical weapons is reduced by 3.

One example of damage resistance is the blade ward cantrip:

You extend your hand and trace a sigil of warding in the air. Until the end of your next turn, you have resistance against bludgeoning, piercing, and slashing damage dealt by weapon attacks.

Let’s assume a character with both effects above is hit by a nonmagical weapon attack dealing slashing damage. The attack deals 10 damage. What happens:

  1. Damage reduction applies reducing damage to 7, then damage resistance (rounds down). Character takes 3 damage.
  2. Damage resistance applies, halving to 5, then damage reduction takes it to 2 damage.