반응형

출처: 프로그래머스 코딩 테스트 연습, 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]

 

참고: https://velog.io/@sem/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-LEVEL2-%ED%8C%8C%EC%9D%BC%EB%AA%85-%EC%A0%95%EB%A0%AC-Python

 

[프로그래머스] 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

 

반응형

+ Recent posts