title: Algorithm to create multiple lists from a single list
body: <p>I have an interface:</p>
  
  <pre><code>List&lt;List&lt;Integer&gt;&gt; separate(List&lt;Integer&gt; list);
  </code></pre>
  
  <p>I want to be able to separate the parameterized list into separate integer lists based on if the values within the list object are the same so if the list was <code>{1, 1, 5, 7, 9}</code> it would create 4 separate lists:</p>
  
  <ul>
  <li><code>{1, 1}</code></li>
  <li><code>{5}</code></li>
  <li><code>{7}</code></li>
  <li><code>{9}</code></li>
  </ul>
  
  <p>Is there an easy library to use for this? I can quite easily come up with an algorithm which does this but if the elements in the list were not <code>Integers</code> but <code>Objects</code> and you wanted to base the grouping rules on some fields within it then how would I go about doing that?</p>
  
  <p>Thanks very much for any help.</p>