Is there a built-in function to sort and filter a python list in one step?
<p>Given a directory of files all with numeric names, I currently sort and filter the directory list in two steps.</p>

<pre><code>#files = os.listdir(path)
files = ["0", "1", "10", "5", "2", "11", "4", "15", "18", "14", "7", "8", "9"]

firstFile =  5
lastFile  = 15

#filter out any files that are not in the desired range
files = filter(lambda f: int(f) &gt;= firstFile and int(f) &lt; lastFile, files)

#sort the remaining files by timestamp
files.sort(lambda a,b: cmp(int(a), int(b)))
</code></pre>

<p>Is there a python function that combines the filter and sort operations so the list only needs to be iterated over once?</p>
