import random


def r_ints(lowest=1, highest=1000, length=500, sorted_=False):
    """ Return a list of random integer values, optionally sorted """
    
    ints = [random.randint(lowest, highest) for _ in range(length)]
    
    if sorted_ in {True, 'ascending'}:
        return sorted(ints)
    elif sorted_ == 'descending':
        return sorted(ints, reverse=True)
    else:
        return ints