def solution(files):
answer = []
for file in files:
# transformed =[์๋ ๋จ์ด, ์๋ฌธ์๋ก ๋ง๋ HEAD, ์์ ๋์ค๋ 0์ ์ ์ธํ NUMBER]
transeformed = []
# ์ซ์๊ฐ ๋์ค๊ธฐ ์์ํ๋ index = first_index
first_index = 0
# ์ซ์๊ฐ ๋๋๋ index + 1 = second_index
second_index = 0
for index in range(len(file)):
# ๋ฌธ์๊ฐ ์ซ์์ด๋ฉด ๊ทธ๊ณณ์ด first_index
if file[index].isdigit():
first_index = index
break
# ์ซ์๋ 5์๋ฆฌ ์๊น์ง ๋์ฌ ์ ์์ผ๋ฏ๋ก ์ ์ ํด์ผ ํ๋ค
for index in range(first_index, min(len(file), first_index + 5)):
# ๋ฌธ์๊ฐ ์ซ์๊ฐ ์๋๋ฉด ๊ทธ๊ณณ์ด second_index
if not file[index].isdigit():
second_index = index
break
else:
# TAIL์ด ์์ ๋๋ ๋ง์ง๋ง ์ธ๋ฑ์ค๋ฅผ ์ ์ ํด์ผ ํ๋ค
second_index = min(len(file), first_index + 5)
transeformed.append(file)
transeformed.append(file[:first_index].lower())
transeformed.append(int(file[first_index:second_index]))
# ์ด๋ ๊ฒ ๊ตฌํ transformed๋ฅผ answer์ ๋ฃ์ด์ค๋ค
answer.append(transeformed)
# ์ด๋ ๊ฒ ๊ตฌํ answer๋ฅผ HEAD๋ก ๋จผ์ ๋๋๊ณ ๋์์ด๋ฉด NUMBER๋ก ์ ๋ ฌํ๋ค
# ๊ทธ๋ฆฌ๊ณ ๊ทธ ์๋ณธ transformed[0]๋ก ๋ฆฌ์คํธ๋ฅผ ๋ง๋ค์ด ๋ฐํํ๋ค
return list(map(lambda y: y[0], sorted(answer, key=lambda x: (x[1], x[2]))))