title: Fastest way to check if two List<T> are equal
body: <p>I have two Lists</p>
  
  <p><code>ListA&lt;Emp&gt;</code> and <code>ListB&lt;Emp&gt;</code> 
  both are having 1000 records.</p>
  
  <p><code>Emp</code> is an object of Employee Class. Below is my <code>Employee</code> class</p>
  
  <pre><code>public class Employee
  {
      int ID = 0;
      string Name = String.Empty;
      string Dept = String.Empty;
      string Address = String.Empty;
      int Age = 0;
      string Email = String.Empty;
  }
  </code></pre>
  
  <p>I want to verify if both the Lists are equal. The Emp objects may be placed in different order. Also, there might be several Emp objects which are having exactly same info in both the list. I have to verify those also.</p>
  
  <p>I tried to sort the lists and compared using <code>SequenceEqual</code></p>
  
  <pre><code>Enumerable.SequenceEqual(ListA.OrderBy(s =&gt; s), ListB.OrderBy(s =&gt; s)
  </code></pre>
  
  <p>I am getting below error </p>
  
  <pre><code>At least one object must implement IComparable.
  Exception Stack trace is as below 
  
     at System.Collections.Comparer.Compare(Object a, Object b)
     at System.Collections.Generic.ObjectComparer`1.Compare(T x, T y)
     at System.Linq.EnumerableSorter`2.CompareKeys(Int32 index1, Int32 index2)
     at System.Linq.EnumerableSorter`1.QuickSort(Int32[] map, Int32 left, Int32 right)
     at System.Linq.EnumerableSorter`1.Sort(TElement[] elements, Int32 count)
     at System.Linq.OrderedEnumerable`1.&lt;GetEnumerator&gt;d__0.MoveNext()
     at System.Linq.Enumerable.SequenceEqual[TSource](IEnumerable`1 first, IEnumerable`1 second, IEqualityComparer`1 comparer)
     at System.Linq.Enumerable.SequenceEqual[TSource](IEnumerable`1 first, IEnumerable`1 second)
  </code></pre>
  
  <p>How can I implement this ? Also it will be better if you guys can provide me the fastest way of doing this because the number of objects in List may grow to 10 million.
  Thanks for your help !</p>
  
  <p><strong>EDIT:</strong> Every employee must be in both list, order does not matter. But, if ListA contains same employee object 5 times (that means some duplicate entries), and ListB contains the employee object 4 times, then ListA and ListB are not equal.</p>