title: Getting distinct and ordered members from a list of strings - linq or hashset for unique which one is faster / better suited
body: <p>I have a big list of strings (about 5k-20k entries) that I need to order and also to remove duplicates from.</p>
  
  <p>I've done this in 2 ways now, once with a hashset and once solely with linq. Tests with that number of entries did not show a big difference but I'm wondering what way and thus what method would be better suited.</p>
  
  <p>For the ways (myList is of the datatype List):</p>
  
  <p><strong>Linq:</strong> I'm using 1 linq statement to order the list and get the distinct values from it.</p>
  
  <pre><code>myList = myList.OrderBy(q =&gt; q).Distinct().ToList();
  </code></pre>
  
  <p><strong>Hashset:</strong> I'm using hashset to remove all duplicates and then I'm ordering the list</p>
  
  <pre><code>myList = new HashSet&lt;String&gt;(myList).ToList&lt;String&gt;();
  myList = myList.OrderBy(q =&gt; q).ToList();
  </code></pre>
  
  <p>Like I said tests I made were about the same time consumption for both methods but I'm still wondering if one method is better than the other and if so why (the code is for a high performance part and I need to get every millisecond I can out of it).</p>