How many duplicates are eliminated via sorting? This is a problem I've encountered when using a set as a key for a lookup table.
Say I have to map a set of letters (lets say, $4$) to some (unspecified) result with a dictionary/array/etc. For simplicity, assume all uppercase, so the entire table would need at most $26^4 = 456976$ entries in order to cover all possible inputs.
$456976$ would be the answer if order mattered. But the $4$ letters can be rearranged. $ABDE = EDBA = ADBE$ etc. Obviously I should normalize all equivalent values into one normalized value (probably via sorting). Only storing sorted entries in my table eliminates many redundant entries (all these other orderings can be erased).
Is there an elegant way to compute the resulting size of the table after this optimization?
 A: Suppose your alphabet has $k$ possible letters and you need to form a key of length $n$ letters from this alphabet. If order doesn't matter then the keys are uniquely identified by a $k$-tuple of non-negative integers adding up to $n$, with the entry in position $i$ giving the number of occurrences of letter $i$. For example if you have $k=26$ letters and need a key of $n=4$ letters, the 26-tuple $(1,2,1,0,\ldots,0)$ (with zero in every position after position 4) represents the key ABBC; the 26-tuple $(0,1,1,1,0,1,0,\ldots,0)$ represents $BCDF$.
The number of such keys is given by 
$${n+k-1\choose n}$$
using the stars-and-bars device (see Theorem 2 in the wiki article); when $n=4$ and $k=26$ this gives
$${29\choose 4}=23751$$
unique keys.
A: Multichoose is what you're looking for I think. In case the link breaks, multichoose uses the notation 
$$\left(\!\!{n\choose k}\!\!\right) = \binom{n+k-1}{k}$$
and gives the ways to choose sets of size $k$ from an alphabet of size $n$ and with repetition allowed. 
A: If you consider all the rearrangements of any four chosen letters as duplicates of one of them which you might call the original, then your problem simply boils down to the following question:

In how many ways can you choose $4$ letters from $26$ different
  letters?


There will be $5$ cases:

$1$. Out of the four letters, all $4$ will be same (like AAAA).
$2$. Out of the four letters, $3$ will be same and $1$ will be
  different (like AAAB).
$3$. Out of the four letters, $2$ will be same and $2$ will be
  different (like AABC).
$4$. Out of the four letters, there will be $2$ pairs of $2$ different
  letters (like AABB).
$5$. Out of the four letters, all $4$ will be different (like ABCD).


For ($1$), we have $26$ choices.
For ($2$), we have $26 \times \binom{25}{1}$ choices since we have $26$ letters from which the same letter can chosen and $25$ to choose the $1$ different.
For ($3$), we have $26 \times \binom{25}{2}$ choices since we have $26$ letters from which the same letter can chosen and $25$ to choose the $2$ different.
For ($4$), we have $\binom{26}{2}$ choices since we have $26$ letters from which the $2$ different letters can chosen.
For ($5$), we have $\binom{26}{4}$ choices which is obvious.
So, in total, you will have a table of size $$26+26 \times \binom{25}{1}+26 \times \binom{25}{2}+\binom{26}{2}+\binom{26}{4}$$
