def sort_key_by_numeric_other(key_value):
    return tuple((
        int(numeric) if numeric else None,
        INSTANCE_SIZES.index(alpha) if alpha in INSTANCE_SIZES else alpha,
        other
    ) for (numeric, alpha, other) in RE_NUMERIC_OTHER.findall(key_value[0]))
Split key into numeric, alpha and other part and sort accordingly.
dataset/ETHPy150Open apache/libcloud/contrib/scrape-ec2-prices.py/sort_key_by_numeric_other