def natural_keys(text):
    """
    alist.sort(key=natural_keys) sorts in human order
    http://nedbatchelder.com/blog/200712/human_sorting.html
    (See Toothy's implementation in the comments)
    """
return [atoi(c) for c in re.split('(\\d+)', text)]
alist = ['something1', 'something12', 'something17', 'something2',
    'something25', 'something29']
alist.sort(key=natural_keys)
How to correctly sort a string with a number inside?