title: Going through elements in treeset and update the sorting in Java
body: <p>I have three set of three sets and I want to do this algorithmically:</p>
  
  <pre><code>For the first treeset in treesets do till all done:
    dosomething(treeset)
    if done(treeset) {
     remove treeset from treesets
     sort treesets
    // now the next treeset to dosomething will be the first treeset in treesets   since we change the sorting but I want to make sure the sorting is applied there
    }
  }
  </code></pre>
  
  <p>What is the best way of doing that? 
  A very simple example:</p>
  
  <pre><code>treeset1
  treeset2
  treeset3
  treeset4
  </code></pre>
  
  <p>Go to treeset1, do something on it, if done, then remove treeset1, sort, next element will become treeset4 (originally was treeset2), now do something on treeset4, not done, do not remove treesert4, sort again, the next is treeset3, do something, done, treeset3 done, sort again, again treeset4 comes up in sortting, do something on treeset4 .....</p>
  
  <p>What is the best practice? I have the sorting function that works. The algorithm will stop once I reach the last element and could not remove any more element. </p>