BrunoVisnadi, not quite, you forgot f) (you also forgot d) and e) but those are ties anyways).
According to the
2018 FIFA World Cup Regulations (Article 32), the ranking in the group stage is decided by:
a) (overall) points
b) (overall) highest goal difference
c) (overall) highest goal number
Now if there are tied teams:
d) (between tied teams) points
e) (between tied teams) highest goal difference
f) (between tied teams) highest goal number
g) fair play conduct by weighting yellow and red cards
h) drawing of lots by FIFA
So if Sweden and Germany were to win 1-0, the ranking would either be
1. Sweden, 2. Germany, 3. Mexico, 4. South Korea
or
1. Germany, 2. Sweden, 3. Mexico, 4. South Korea
(if cards stay as is, the former one happens; if Sweden gets too many cards, the latter one happens; if they are tied then it's randomly decided)
The part BrunoVisnadi missed was: three teams were tied, so the matches against South Korea are not counted anymore, meaning the goals look like this:
Sweden: 2-2
Germany: 2-2
Mexico: 1-1
So according to f), Mexico is 3rd place no matter what the weighting of cards say.
(Fun fact: If instead of those teams winning 1-0, they both win 2-0, then the ranking is the latter one no matter what, because in a direct tie between Germany and Sweden, Germany wins simply because they won the game against Sweden.)