Python 제타정렬

1 개요[ | ]

Python 제타정렬
import re
fruits = ['바나나','banana','멜론B','멜론 A','멜론A','사과11','사과9','사과들','사과22','pineapple','파인애플','사과','레몬']
fruits.sort(key=lambda s: (2*len(s)-len(re.findall('[ -~]',s)),s))
print( fruits )

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}