title: sorting list of strings based on date 20210419
body: <p>I have. list of files, names of the files are <code>log20211904.json</code> what would be the best way to sort this name based on the date that is included in the name of the file? What I get now from my method substring is 20210419 which is not valid date time. I wonder how to do it effectively and get valid DateTimeOffset from 20210419</p>
  <p>I was thinking</p>
  <pre><code>var orderedFIle = new List&lt;LogFile&gt;();
          
  var fileDetail = new LogFile()
  {
      FileName = &quot;log20210419&quot;,
  
  };
  var fileDetailtest = new LogFile()
  {
      FileName = &quot;log20210420&quot;,
  
  };
  var test = fileDetail.FileName.Substring(3, 8);
  Console.WriteLine(test);
  orderedFIle.Add(fileDetail);
  orderedFIle.Add(fileDetailtest);
  
  var  list = orderedFIle.OrderByDescending(f =&gt; DateTime.Parse(f.FileName.Substring( 3,8)));
  foreach (var VARIABLE in list)
  {
      Console.WriteLine(VARIABLE.FileName);
  }
  </code></pre>
  <p>But the date is actually without  separators. What would be the best approach</p>