title: Sorting Values of Set
body: <p>I am trying to sort elements of a set but unable to do so far.
  here is my code which i am trying to do</p>
  
  <pre><code>public static void main(String [] args){
      Set&lt;String&gt; set=new HashSet&lt;String&gt;();
      set.add("12");
      set.add("15");
      set.add("5");
      List&lt;String&gt; list=asSortedList(set);
  }
  
  public static
  &lt;T extends Comparable&lt;? super T&gt;&gt; List&lt;T&gt; asSortedList(Collection&lt;T&gt; c) {
    List&lt;T&gt; list = new ArrayList&lt;T&gt;(c);
    Collections.sort(list);
    return list;
  }
  </code></pre>
  
  <p>but this or other way is not working since its all time giving me the same order in which they have been filled
  12,15,5</p>