title: Order list elements in R
body: <p>I have some files like </p>
  
  <pre><code>myfiles &lt;- c("1850-12.dat", "1851-10.dat", "1851-11.dat", "1851-1.dat",  "1851-6.dat", 
  "1851-7.dat", "1851-8.dat",  "1852-10.dat", "1852-11.dat", "1852-12.dat",
  "1852-1.dat",  "1852-2.dat",  "1852-3.dat",  "1852-4.dat",  "1852-7.dat", 
  "1852-8.dat",  "1852-9.dat",  "1853-10.dat", "1853-11.dat", "1853-12.dat")
  </code></pre>
  
  <p>where the first number is the year and the second one is the month and I put them in a list with</p>
  
  <pre><code>myfilesContent &lt;- lapply(myfiles, read.table, quote="\"")
  </code></pre>
  
  <p>I renamed the names of each element with</p>
  
  <pre><code>myfilesContent &lt;- setNames(myfilesContent,myfiles)
  &gt;myfilesContent[1]
  
  $`1850-12.dat`
      V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20 V21
      .
      .
      .
  </code></pre>
  
  <p>What I would like to do is then to reorder the list elements according to the year and month information.</p>
  
  <p>What I have done is to rename them with a value of the days since year, so the names of each list element look like</p>
  
  <pre><code>&gt; names(myfilesContent)
    [1] "335"   "639"   "670"   "366"   "517"   "547"   "578"   "1005"  "1036" 
   [10] "1066"  "731"   "762"   "791"   "822"   "913"   "944"   "975"   "1370" 
   [19] "1401"  "1431"  "1097"  "1128"  "1156"  "1187"  "1217"  "1248"  "1309" 
   [28] "1340"  "1735"  "1766"  "1796"  "1462"  "1493"  "1521"  "1552"  "1582" 
  </code></pre>
  
  <p>but then I don't know how to sort them.</p>
  
  <p>Many thanks</p>