Java sort via bucket value
<p>Am trying to sort via a certain value in the function,</p>

<pre><code> Collection users = roster.getEntries();
 if(!users.isEmpty()) {

 Iterator userIterator = users.iterator();
 while(userIterator.hasNext()) {
      String name = user.getName()==null?user.getUser():user.getName();
</code></pre>

<p>Now before iterating, I want to sort this Collection by the user's name. Any suggestions on how to go about this?</p>

<p>Thank you for your time.</p>
