def _by_version_descending(names):
def _by_version(name):<EOL><INDENT>"""<STR_LIT>"""<EOL>name, ext = os.path.splitext(name)<EOL>parts = itertools.chain(name.split('<STR_LIT:->'), [ext])<EOL>return [packaging.version.parse(part) for part in parts]<EOL><DEDENT>return sorted(names, key=_by_version, reverse=True)<EOL>
Given a list of filenames, return them in descending order
by version number.

>>> names = 'bar', 'foo', 'Python-2.7.10.egg', 'Python-2.7.2.egg'
>>> _by_version_descending(names)
['Python-2.7.10.egg', 'Python-2.7.2.egg', 'foo', 'bar']
>>> names = 'Setuptools-1.2.3b1.egg', 'Setuptools-1.2.3.egg'
>>> _by_version_descending(names)
['Setuptools-1.2.3.egg', 'Setuptools-1.2.3b1.egg']
>>> names = 'Setuptools-1.2.3b1.egg', 'Setuptools-1.2.3.post1.egg'
>>> _by_version_descending(names)
['Setuptools-1.2.3.post1.egg', 'Setuptools-1.2.3b1.egg']