Let $f: X \times Y \rightarrow \mathbb{R}$ be a continuous function, where $X \subset \mathbb{R}^n$ and $Y \subset \mathbb{R}^m$ are compact sets.
Say under which conditions we have that
$ \max_{x \in X} \max_{y \in Y} f(x,y) = \max_{y \in Y} \max_{x \in X} f(x,y) $