它称为“自然排序顺序”,来自http://www.codinghorror.com/blog/2007/12/sorting-for-humans- natural-sort-order.html
尝试这个:
import re
def sort_nicely( l ):
""" Sort the given list in the way that humans expect.
"""
convert = lambda text: int(text) if text.isdigit() else text
alphanum_key = lambda key: [ convert(c) for c in re.split('([0-9]+)', key) ]
l.sort( key=alphanum_key )