def sort_nicely ( l ) : 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 )
how to reverse sort a list alphanetically in python
Sort the given list in the way that humans expect .
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)