title: sorted() fails on the very first call only
body: <p>I'm using python 3.7.4. The data I'm trying to sort is in a series of csv files with the format '1234_5678.A.csv','1234_5678.B.csv','1234_5678.C.csv','1234_5678.D.csv', etc..</p>
  
  <p>Code is as follows:</p>
  
  <pre><code>import sys
  ## GET ALL CSV Files in a folder
  import os
  import glob
  
  def filter_name(filterString, fileNames):
      filtered = []
      for name in fileNames:
          if filterString in name:
              filtered.append(name)
      return filtered
  
  def sort_key(fileName):
      """Assumes file name of 12345_9876.A.csv structure
      returns 9876 value"""
      _, backhalf = fileName.split("_")
      return backhalf.split(".")[0]
  
  file_path=r'C:\\Auto\\201907 compare\\AEG data\\#1022206 abcdef879 S1 - doneagain\\orig - Copy\\'
  path = file_path
  extension = 'csv'
  #os.chdir(path)  # TODO This might be causing more problems than just the image packing thing...
  listOfFiles = [i for i in glob.glob(os.path.join(path, '*.{}').format(extension))]
  
  listOfFiles = ['C:\\Auto\\201907 compare\\AEG data\\#1022206 abcdef879 S1 - doneagain\\orig - Copy\\20190531_155638064567.A.csv',
  'C:\\Auto\\201907 compare\\AEG data\\#1022206 abcdef879 S1 - doneagain\\orig - Copy\\20170532_155646505788.B.csv',
  'C:\\Auto\\201907 compare\\AEG data\\#1022206 abcdef879 S1 - doneagain\\orig - Copy\\20170532_155654944787.C.csv',
  'C:\\Auto\\201907 compare\\AEG data\\#1022206 abcdef879 S1 - doneagain\\orig - Copy\\20170532_155703390027.D.csv',
  'C:\\Auto\\201907 compare\\AEG data\\#1022206 abcdef879 S1 - doneagain\\orig - Copy\\20170532_155901884437.A.csv',
  'C:\\Auto\\201907 compare\\AEG data\\#1022206 abcdef879 S1 - doneagain\\orig - Copy\\20170532_155910324109.B.csv',
  'C:\\Auto\\201907 compare\\AEG data\\#1022206 abcdef879 S1 - doneagain\\orig - Copy\\20170532_155918771536.C.csv',
  'C:\\Auto\\201907 compare\\AEG data\\#1022206 abcdef879 S1 - doneagain\\orig - Copy\\20170532_155927211990.D.csv']
  
  
  ###listOfFiles = ['20170532_155638064567.A.csv', '20190732_155646505788.B.csv', '20190732_155654944787.C.csv', '20190732_155703390027.D.csv', '20170532_155901884437.A.csv', '20170532_155910324109.B.csv', '20190732_155918771536.C.csv', '20190732_155927211990.D.csv']
  
  Afilenames = sorted(filter_name("A", listOfFiles), key=sort_key)
  Bfilenames = sorted(filter_name("B", listOfFiles), key=sort_key)
  Cfilenames = sorted(filter_name("C", listOfFiles), key=sort_key)
  Dfilenames = sorted(filter_name("D", listOfFiles), key=sort_key)
  
  
  
  
  print("# Of Files: \n")
  print(len(listOfFiles))
  print("List Of Files: \n")
  print(listOfFiles)
  
  print("# Of A Files: \n")
  print(len(Afilenames))
  print("# Of B Files: \n")
  print(len(Bfilenames))
  print("# Of C Files: \n")
  print(len(Cfilenames))
  print("# Of D Files: \n")
  print(len(Dfilenames))
  </code></pre>
  
  <p>The output of the print statements is incorrect.</p>
  
  <pre><code>Total files = 8
  Total A files = 8 
  Total B files = 2
  </code></pre>
  
  <p>This is a bizarre problem..any hints?</p>