Test Formatter (#100)

This commit is contained in:
Bao Le 2024-01-09 02:27:20 +08:00 committed by GitHub
parent 14ecef649e
commit 04c6af1dff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 1624 additions and 0 deletions

View file

@ -0,0 +1,15 @@
def get_char_kind(char):
return 1 if char.isdigit() else 2 if char.isalpha() else 3
def natural_sorting_key(name):
result = []
last_kind = -1
for char in name:
curr_kind = get_char_kind(char)
if curr_kind != last_kind:
result.append("")
result[-1] += char
last_kind = curr_kind
return [x.zfill(16) if x.isdigit() else x for x in result]