In order to use correct notation, you should note that you are dealing with a sequence, rather than a set. It is conceivable that the "set of ages" you present may have duplicate elements. In addition, you impose an order on the "set" by saying you want to take the last two. These properties are characteristic of a sequence but not of a set.
The same probably applies to your result. Presumably, if the last two elements of your sequence have the same value, you want the result to be a sequence of these two values.
It seems to me that operations on whole sequences are not very common in mathematics, however I can imagine they can be very useful. With all this in mind, we can make the following definitions, where the last definition is the one we are after. Note that we are implicitly assuming here that sequences start with index 1, although it also common to start indexing at 0.
Definition
Let $N \in \mathbb{N}$ and for all $1 \le i \le N$ let $ \ a_i \in \mathbb{R}$ and let $A = (a_i)_{i=1}^N$ be a sequence. We define $\text{sort}(A)$ as the unique nondecreasing sequence $B = (b_i)_{i=1}^N$ satisfying
$$
\forall 1 \le k \le N \quad |\lbrace i \in \mathbb{N} \,|\, a_i = a_k \rbrace| = |\lbrace i \in \mathbb{N} \,|\, b_i = a_k \rbrace|
$$
Note that the last equation above in words is just: $A$ has the same elements as $B$ (and when there is duplication, duplicate elements occur equally often). Probably it is more convenient to use the following instead, which just uses words.
Definition (alternative)
Let $A$ be a sequence of real numbers. We define the sequence $\text{sort}(A)\subset \mathbb{R}$ to be the result of sorting $A$, preserving duplicate elements.
Using either definition of "sort", we can then define what you want.
Definition
Let $N, K \in \mathbb{N}$ and for all $1 \le i \le N$ let $ \ a_i \in \mathbb{R}$ and let $A = (a_i)_{i=1}^N$ be a sequence. Let $B = (b_i)_{i=1}^N = \text{sort}(A)$. We define $A^{(K)}$ to be the sequence $A^{(K)} = (c_i)_{i=1}^K$ of real numbers satisfying, for all $1 \le i \le K$, $c_i = b_{N-K+i}$.