MCPcopy Create free account
hub / github.com/NatsUIJM/autoContents / natural_sort_key

Function natural_sort_key

mainprogress/content_postprocessor.py:16–25  ·  view source on GitHub ↗

自然排序键函数

(path: Path)

Source from the content-addressed store, hash-verified

14
15
16def natural_sort_key(path: Path) -> tuple:
17 """自然排序键函数"""
18 parts = re.split(r'(\d+)', path.name)
19 result = []
20 for part in parts:
21 try:
22 result.append(int(part))
23 except ValueError:
24 result.append(part)
25 return tuple(result)
26
27
28def read_json_file(file_path: Path) -> list:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected