def _format_years(years):
def sub(x):<EOL><INDENT>return x[<NUM_LIT:1>] - x[<NUM_LIT:0>]<EOL><DEDENT>ranges = []<EOL>for k, iterable in groupby(enumerate(sorted(years)), sub):<EOL><INDENT>rng = list(iterable)<EOL>if len(rng) == <NUM_LIT:1>:<EOL><INDENT>s = str(rng[<NUM_LIT:0>][<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>s = "<STR_LIT>".format(rng[<NUM_LIT:0>][<NUM_LIT:1>], rng[-<NUM_LIT:1>][<NUM_LIT:1>])<EOL><DEDENT>ranges.append(s)<EOL><DEDENT>return "<STR_LIT:U+002CU+0020>".join(ranges)<EOL>
Format a list of ints into a string including ranges

    Source: https://stackoverflow.com/a/9471386/1307974