How to Select then OrderBy using LINQ?
<p>I am trying to sort the contents of a CSV file according to their dates with the following code from a <a href="https://stackoverflow.com/questions/37200307/where-to-add-an-if-statement-inside-for-foreach-loop">question</a> a posted earlier:</p>

<pre><code>private class CSVEntry
{
    public DateTime Date { get; set; }
    public string Grp { get; set; }
}

...

List&lt;CSVEntry&gt; csvList = new List&lt;CSVEntry&gt;();

csvList.Add(new CSVEntry() { Date = DateTime.ParseExact(col[7], "dd/MM/yyyy", null), Grp = col[9] });

var results = csvList.OrderBy(x =&gt; x.Date); // An error occurs at "Date".

...
</code></pre>

<p>But I got this error:</p>

<blockquote>
  <p>'string' does not contain a definition for 'Date' and no extension method 'Date' accepting a first argument of type 'string' could be found.</p>
</blockquote>

<p>What I want the output to be is the strings from other columns but sorted chronologically. When I tried using this code to display the dates:</p>

<pre><code>var results = csvList.Where(x =&gt; x.Grp == "DEFAULT").OrderBy(x =&gt; x.Date);
</code></pre>

<p>It works perfectly with the output as dates sorted chronologically. However, this time I don't want to display the dates. I want to display the strings from other columns like I've mentioned above. I tried using</p>

<pre><code>var results = csvList.Select(x =&gt; x.Grp).OrderBy(x =&gt; x.Date);
</code></pre>

<p>but got the same error as well. Where have I gone wrong? I am new to LINQ and unfamiliar with <code>List&lt;T&gt;</code> and <code>IEnumerable&lt;T&gt;</code> and this is my first time using them.</p>