import re


def humansort_key(strng):
    """Human/natural sort key-gathering function for sorted()
    Source: http://stackoverflow.com/a/1940105
    """
    if isinstance(strng, tuple):
        strng = strng[0]
    return [w.isdigit() and int(w) or w.lower()
            for w in re.split(r'(\d+)', strng)]