title: SortedSet<TestClass> comparing on equality one field and sorting by another
body: <p>Please review code:</p>
  
  <pre><code>/* Run1.java */
  package test;
  
  import java.util.Iterator;
  import java.util.SortedSet;
  import java.util.TreeSet;
  
  public class Run1 
  {
      static public void main(String[] args)
      {
          SortedSet&lt;TestClass&gt; s = new TreeSet&lt;TestClass&gt;(); 
  
          s.add( new TestClass("name1", 100) );
          s.add( new TestClass("name2", 10) );
          s.add( new TestClass("name3", 1) );
          s.add( new TestClass("name4", 10) );
          s.add( new TestClass("name5", 100) );
  
          Iterator&lt;TestClass&gt; it = s.iterator();
  
          while(it.hasNext())
          {
              TestClass t = it.next();
              System.out.println( t.name+' '+t.value );
          }
      }
  }
  
  /* TestClass.java */
  package test;
  
  public class TestClass implements Comparable&lt;TestClass&gt; 
  {
      public String name;
      public int value;
  
      public TestClass(String name, int value) {
          this.name = name;
          this.value = value;
      }
  
      public int compareTo(TestClass o) 
      {
          return this.value - o.value;
      }
  
      public boolean equals(Object o) 
      {
          if (!(o instanceof TestClass))
              return false;
          TestClass n = (TestClass)o;
  
          return this.name.equals(n.name);
      }
  
      public int hashCode() 
      {
          return 31*name.hashCode();
      }
  
      public String toString() 
      {
          return name;
      }
  }
  </code></pre>
  
  <p>Print out </p>
  
  <pre><code>name3 1
  name2 10
  name1 100
  </code></pre>
  
  <p>as i see because <code>compareTo</code> used for checking to equality (when returned 0). But i need check for unique by field <code>TestClass.name</code> and only sort by <code>TestClass.value</code></p>