Mathematical expression for $n$ largest values in a set

I would like to know how to express mathematically $n$ largest values of a given set $A$.

For example: I have an unsorted set $A$ with $100$ values $\in \mathbb{N}$ and want to get a new set $B$ with the $5$ largest values.

Thank you in advance!

Solutions Collecting From Web of "Mathematical expression for $n$ largest values in a set"

I don’t think you can do this in any easy way, unless you basically write a sentence to define the set. However, you could do it inductively:

Define $A=A_0$. Write $$B_1:=\{b\in A_0: b\geq a\:\forall\: a\in A_0\}$$ and define $A_1:=A_0\setminus B_1$. Then inductively, write $$B_{i+1}:=\{b\in A_i: b\geq a\:\forall\: a\in A_i\}$$ and define $A_{i+1}:=A_i\setminus B_{i+1}$. Then $B_5$ is the set you are after.

EDIT: In the comments you said that $A$ can be a multiset, and so can have more than one element of a given value. This means that, in the above, $B_5$ could be the entire set $A$. (For example, take $A=\{3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, \ldots\}$). So, what you want to do is set $\overline{B}:=B_i$ where $|B_i|\geq 5$ but $|B_{i-1}|<5$, set $C:=B_i\setminus B_{i+1}$ (these are the elements which we want to remove some of) and set $\overline{C}$ to be a subset of $C$ with $|\overline{B}|-5$ elements. Then take $B:=\overline{B}\setminus\overline{C}$.

There has to be a neater way though!

It can be done using 5 iterations of removing the maximum element from set $A=A_0,A_1,\cdots,A4$ define $A_{k+1}=A_{k}-Max(A_k)$where a maximum exits, and let $B_k=A_{k}-A_{k+1} $ then the set $\cup_{k=0}^{4}B_k$ is the set of top 5 largest elements.