프로그래머스/level 2
[프로그래머스] 파일명 정렬
binaryJournalist
2021. 12. 28. 20:36
반응형
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges
import re
def solution(files):
reg = [re.split(r'(\d+)', s) for s in files]
reg.sort(key = lambda x: (x[0].lower(), int(x[1])))
return [''.join(s) for s in reg]
[프로그래머스] LEVEL2 파일명 정렬 (Python)
프로그래머스 알고리즘 풀이
velog.io
참고: https://stackoverflow.com/questions/430079/how-to-split-strings-into-text-and-number
How to split strings into text and number?
I'd like to split strings like these 'foofo21' 'bar432' 'foobar12345' into ['foofo', '21'] ['bar', '432'] ['foobar', '12345'] Does somebody know an easy and simple way to do this in python?
stackoverflow.com
반응형