import re


def natural_sort(values, case_sensitive=False):
    """
    Returns a human readable list with integers accounted for in the sort.
    items = ['xyz.1001.exr', 'xyz.1000.exr', 'abc11.txt', 'xyz.0999.exr', 'abc10.txt', 'abc9.txt']
    natural_sort(items) = ['abc9.txt', 'abc10.txt', 'abc11.txt', 'xyz.0999.exr', 'xyz.1000.exr', 'xyz.1001.exr']
    :param values: string list
    :param case_sensitive: Bool. If True capitals precede lowercase, so ['a', 'b', 'C'] sorts to ['C', 'a', 'b']
    :return: list
    """
    def alpha_to_int(a, _case_sensitive=False):
        return int(a) if a.isdigit() else (a if _case_sensitive else a.lower())

    def natural_sort_key(_values):
        try:
            return tuple(alpha_to_int(c, case_sensitive) for c in re.split('(\d+)', _values) if c)
        except (TypeError, ValueError):
            return _values

    return sorted(values, key=natural_sort_key)