def general_sort(lst, keys, reverses):
    """A more general version of list.sort() that supports a number of key
    functions with independent reverse flags.
    """
    # for key, reverse in zip(keys, reverses):
    #     values = sorted((key(x) for x in lst), reverse=reverse)
    #     indices.append({v: i for i, v in enumerate(values)})

    def indexmap(key, reverse):
        """Create mapping from key(item) to index when sorted."""
        values = sorted((key(x) for x in lst), reverse=reverse)
        return {v: i for i, v in enumerate(values)}
    maps = [indexmap(k, r) for k, r in zip(keys, reverses)]

    def final_key(entry):
        """Construct sortkey for list.sort()."""
        return [m[k(entry)] for m, k in zip(maps, keys)]
    lst.sort(key=final_key)
    return lst