title: Python - Sort files based on timestamp
body: <p>I have a list which contains list of file names, i wanted to sort based on timestamp, which ( i.e timestamp ) is inbuild in each file name.  </p>
  
  <p>Note: In file, Hello_Hi_2015-02-20T084521_1424543480.tar.gz --> 2015-02-20T084521 represents as "year-moth-dayTHHMMSS" ( Based on this i wanted to sort )  </p>
  
  <p>Input file below:  </p>
  
  <pre><code>file_list = ['Hello_Hi_2015-02-20T084521_1424543480.tar.gz',  
  'Hello_Hi_2015-02-20T095845_1424543481.tar.gz',  
  'Hello_Hi_2015-02-20T095926_1424543481.tar.gz',  
  'Hello_Hi_2015-02-20T100025_1424543482.tar.gz',  
  'Hello_Hi_2015-02-20T111631_1424543483.tar.gz',  
  'Hello_Hi_2015-02-20T111718_1424543483.tar.gz',  
  'Hello_Hi_2015-02-20T112502_1424543483.tar.gz',  
  'Hello_Hi_2015-02-20T112633_1424543484.tar.gz',  
  'Hello_Hi_2015-02-20T113427_1424543484.tar.gz',  
  'Hello_Hi_2015-02-20T113456_1424543484.tar.gz',  
  'Hello_Hi_2015-02-20T113608_1424543484.tar.gz',  
  'Hello_Hi_2015-02-20T113659_1424543485.tar.gz',  
  'Hello_Hi_2015-02-20T113809_1424543485.tar.gz',  
  'Hello_Hi_2015-02-20T113901_1424543485.tar.gz',  
  'Hello_Hi_2015-02-20T113955_1424543485.tar.gz',  
  'Hello_Hi_2015-03-20T114122_1424543485.tar.gz',  
  'Hello_Hi_2015-02-20T114532_1424543486.tar.gz',  
  'Hello_Hi_2015-02-20T120045_1424543487.tar.gz',  
  'Hello_Hi_2015-02-20T120146_1424543487.tar.gz',  
  'Hello_WR_2015-02-20T084709_1424543480.tar.gz',  
  'Hello_WR_2015-02-20T113016_1424543486.tar.gz']  
  </code></pre>
  
  <p>Output should be:</p>
  
  <pre><code>file_list = ['Hello_Hi_2015-02-20T084521_1424543480.tar.gz',  
  'Hello_WR_2015-02-20T084709_1424543480.tar.gz',  
  'Hello_Hi_2015-02-20T095845_1424543481.tar.gz',  
  'Hello_Hi_2015-02-20T095926_1424543481.tar.gz',  
  'Hello_Hi_2015-02-20T100025_1424543482.tar.gz',  
  'Hello_Hi_2015-02-20T111631_1424543483.tar.gz',  
  'Hello_Hi_2015-02-20T111718_1424543483.tar.gz',  
  'Hello_Hi_2015-02-20T112502_1424543483.tar.gz',  
  'Hello_Hi_2015-02-20T112633_1424543484.tar.gz',  
  'Hello_WR_2015-02-20T113016_1424543486.tar.gz',  
  'Hello_Hi_2015-02-20T113427_1424543484.tar.gz',  
  'Hello_Hi_2015-02-20T113456_1424543484.tar.gz',  
  'Hello_Hi_2015-02-20T113608_1424543484.tar.gz',  
  'Hello_Hi_2015-02-20T113659_1424543485.tar.gz',  
  'Hello_Hi_2015-02-20T113809_1424543485.tar.gz',  
  'Hello_Hi_2015-02-20T113901_1424543485.tar.gz',  
  'Hello_Hi_2015-02-20T113955_1424543485.tar.gz',  
  'Hello_Hi_2015-02-20T114532_1424543486.tar.gz',  
  'Hello_Hi_2015-02-20T120045_1424543487.tar.gz',  
  'Hello_Hi_2015-02-20T120146_1424543487.tar.gz',  
  'Hello_Hi_2015-03-20T114122_1424543485.tar.gz']  
  </code></pre>
  
  <p>Below is the code which i have tried.  </p>
  
  <pre><code>def sort( dir ):
     os.chdir( dir )
     file_list = glob.glob('Hello_*')
     file_list.sort(key=os.path.getmtime)
     print("\n".join(file_list))
     return 0
  </code></pre>
  
  <p>Thanks in advance!!</p>