import re


def sorted_alphanumeric(l, reverse=False):
    """
    Sorts the given iterable alphanumerically.
    If values are numeric, sort numerically; if strings, alphanumerically.
    If string operations don't work we just sort normally; this works for
    numeric types.
    """
    try:
        convert = lambda text: int(text) if text.isdigit() else text
        alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
        return sorted(l, key=alphanum_key, reverse=reverse)
    except TypeError:
        return sorted(l, reverse=reverse)