Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
重複の可能性: Pythonで、英数字の前に英数字を並べ替えるように、英数字の文字列のリストを自然に並べ替えるにはどうすればよいですか?
Pythonで数字と文字を含む文字列をどのように並べ替えますか?
>>> s = '13abc3' >>> ''.join(sorted(s, key=lambda x: int(x) if x.isdigit() else x)) '133abc'
それがあなたが求めているものである場合、これはカスタムソートを処理しません(これは数字、大文字、小文字になります)。