title: How can I make a list of files in a directory where the files in that directory are first before files in subdirectories in python?
body: <p>I'm trying to make a list of files, using recursion, in a given directory. I have been able to do this correctly but the order of my list is not correct. I need the files on the most surface layer of the directory show first in the list with the other files in subdirectories being in lexicographical order after.</p>
  <p>Here is the code I have to do what I've discussed above.</p>
  <pre><code>import os
  important = []
  def search_directory(folder):
       hold = os.listdir(folder)
       for i in hold:
            test = os.path.join(folder, i)
            if os.path.isfile(test) == True and 
                 os.path.isfile(test) not in interesting:
                 interesting.append(test)
            else:
                 search_directory(test)
       return important
  </code></pre>