Ordering slightly shuffled list by order of most frequent occurrence
<p>Let's say you have a list of items that are in "slight disarray". In his example, Blue is <em>mostly</em> on top, Red is <em>mostly</em> in the middle and Green is <em>mostly</em> in the bottom.</p>

<pre><code>Blue
Blue
Blue
Red
Blue
Green
Red
Red
Red
Blue
Green
Green
Green
Blue
</code></pre>

<p>Is there an algorithm that goes: Well, most of the Blue are in the beginning, so we'll put them first. Most of the Red are in the middle, so they come next, and so on, producing the following output:</p>

<pre><code>Blue
Blue
Blue
Blue
Blue
Blue
Red
Red
Red
Red
Green
Green
Green
Green
</code></pre>

<p>Or simply just:</p>

<pre><code>Blue
Red
Green
</code></pre>