https://programmers.co.kr/learn/courses/30/lessons/17686
Code
1
2
3
4
5
6
7
8
import re
def solution(files):
files_proc = []
for idx, file in enumerate(files):
rst = re.match("([\D]*)([\d]{1,5}).*", file.lower())
files_proc.append((rst.group(1), f"{rst.group(2):>05}", idx))
return [files[idx] for _, _, idx in sorted(files_proc)]
Complexity
$O(|\text{files}|^2)$
PREVIOUSEtc