title: C# - Failed to compare two elements in the array
body: <p>This is my code:</p>
  
  <pre><code> var distinctDateValues = dt.AsEnumerable()
                     .Select(row =&gt; new
                     {
                         Date = DateTime.Parse(row.Field&lt;string&gt;("DAY"))
                     })
                     .Distinct()
                     .ToList();
  
   distinctDateValues.Sort(); // getting error on this line
  </code></pre>
  
  <p>Values in distinctDateValues are:</p>
  
  <p><img src="https://i.stack.imgur.com/OMMmR.png" alt="enter image description here"></p>
  
  <p>The error i am getting is "Failed to compare two elements in the array."</p>
  
  <p>Can anybody suggest me as what i am doing wrong here. I want to sort the values in date column of distinctDateValues.</p>