def extractDigits(key):
    """Split a string which may contain a number into
    a tuple of the string without the digits, and the
    integer value of the digits. We can then use that as
    a good thing to sort on, so that we get
    "a5" and "a15" right.
    """
    text = ""
    digits = ""
    for c in key:
        if c in "0123456789":
            digits += c
        else:
            text += c
    return (text, 0 if not digits else int(digits))