Skip to content

Instantly share code, notes, and snippets.

@sagorbrur
Created September 26, 2019 07:46
Show Gist options
  • Save sagorbrur/d9d7354a488daf22861f9c319b1bf720 to your computer and use it in GitHub Desktop.
Save sagorbrur/d9d7354a488daf22861f9c319b1bf720 to your computer and use it in GitHub Desktop.
# glob list has a sorting problem. this scrip will solve this issue.
import glob
files = glob.glob('test/*.txt')
files.sort(key=lambda var:[int(x) if x.isdigit() else x for x in re.findall(r'[^0-9]|[0-9]+', var)])
for file in files:
print(file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment