Jul-10-2019, 04:48 AM
Something like this:
lst = ['python-3.4.0-foo.gz', 'python-3.4.1-foo.gz', 'python-3.4.10-foo.gz', 'python-3.4.2-foo.gz', 'python-3.4.3-foo.gz', 'python-3.4.4-foo.gz', 'python-3.4.5-foo.gz', 'python-3.4.6-foo.gz', 'python-3.4.7-foo.gz', 'python-3.4.8-foo.gz', 'python-3.4.9-foo.gz', 'python-3.5.0-foo.gz', 'python-3.5.1-foo.gz', 'python-3.5.2-foo.gz', 'python-3.5.3-foo.gz', 'python-3.5.4-foo.gz', 'python-3.5.5-foo.gz', 'python-3.5.6-foo.gz', 'python-3.5.7-foo.gz'] def by_version(row): return [int(num) for num in row.split('-')[1].split('.')] sorted(lst, key=by_version)
Output:['python-3.4.0-foo.gz', 'python-3.4.1-foo.gz', 'python-3.4.2-foo.gz', 'python-3.4.3-foo.gz', 'python-3.4.4-foo.gz', 'python-3.4.5-foo.gz', 'python-3.4.6-foo.gz', 'python-3.4.7-foo.gz', 'python-3.4.8-foo.gz', 'python-3.4.9-foo.gz', 'python-3.4.10-foo.gz', 'python-3.5.0-foo.gz', 'python-3.5.1-foo.gz', 'python-3.5.2-foo.gz', 'python-3.5.3-foo.gz', 'python-3.5.4-foo.gz', 'python-3.5.5-foo.gz', 'python-3.5.6-foo.gz', 'python-3.5.7-foo.gz']
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.