Skip to content

Instantly share code, notes, and snippets.

@minhoryang
Created December 13, 2022 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minhoryang/791fca9fa5c634bdf470b9bf24be1ca7 to your computer and use it in GitHub Desktop.
Save minhoryang/791fca9fa5c634bdf470b9bf24be1ca7 to your computer and use it in GitHub Desktop.
sortkey_natural natual/human sort
def sortkey_natural(s):
return tuple(
int(part) if re.match(r'[0-9]+$', part) else part
for part in re.split(r'([0-9]+)', s)
)
@minhoryang
Copy link
Author

@minhoryang
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment