Why do the big nuts always remain at top? The Brazil-nut Effect
The process you describe is called granular convection$^1$. It happens because under random motion it's easier for a small particle to fall under a big one than vice versa.
Let's assume that all the particles are made of the same material so there are no density differences in play. If you agitate the particles then temporary voids will open between particles as they randomly move. These voids will have a size distribution with lots of small voids and few large ones because it takes much less energy to create a small void than a large void. Small particles can fall into small voids, but a large particle can move downwards only if a large void appears. That means it's more likely for a small particle to move downwards than a large one. Over time the result is that small particles move downwards more often than large particles and hence small particles end up at the bottom and large particles at the top.
This is not the lowest energy state, because the greatest packing fraction is achieved with a mixture of particle sizes. Separating the mixture into layers of roughly similar particle size will decrease its density and hence increase its gravitational potential energy. The sorting is a kinetic effect and the sorted system is in principle metastable.
$^1$ I've linked the Wikipedia article, but actually I don't think the article is particularly rigorous and you should Google for more substantive articles.
I googled it and found the term Brazil-nut Effect but couldn't found any proper explanation. What is the physical explanation of this effect?
I answered another question on granular convection some time ago, this is the physical explanation:
When you shake a mixture you create some gaps between the nuts. Because of gravity, small nuts will fall into the gaps between the other nuts, which are too small to be filled by larger nuts. But these will rise only when the KE from the shake is greater than the PE needed to scale the diameter of one small nut: \textrm{KE} > \textrm{PE} $$ E_k = \frac {1}{2} \cdot mv^2 > \textrm{PE} = mgd \rightarrow v^2 > gd$$
At 1:25 in this video you can see that in 10 seconds all big nuts come on top from the bottom, the nuts make a loop in the cup whose mean radius we can guess r = 2 cm, the frequency of the shakes roughly 4 Hz and the diameter of a nut less than 5 mm, therefore the mean speed is: $$ V_\textrm{nut} = 2\pi \cdot r \cdot \nu = 0.5~\textrm{m/s} \rightarrow 2E_k/m = v^2 = 0.25~\textrm{J} > 0.044~\textrm{J} = \textrm{PE}/m = (9.8 \cdot 0.0045)$$ The kinetic energy is more than 5 times the potential energy and the big nuts come on top
Experiments made in reduced gravity show that this phenomenon is linearly dependent on gravity. This phenomenon can also explain mysterious boulders on asteroids