<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sort_resources(cls, request, resources, fail_enum, header_proto=None):
 """Sorts a list of resources based on a list of sort controls Args: request (object):
 The parsed protobuf request object resources (list of objects):
 The resources to be sorted fail_enum (int, enum):
 The enum status to raise with invalid keys header_proto(class):
 Class to decode a resources header Returns: list: The sorted list of resources """

        if not request.sorting:
            return resources

        value_handlers = cls._get_handler_set(request, fail_enum, header_proto)

        def sorter(resource_a, resource_b):
            for handler in value_handlers:
                val_a, val_b = handler.get_sort_values(resource_a, resource_b)

                if val_a < val_b:
                    return handler.xform_result(-1)
                if val_a > val_b:
                    return handler.xform_result(1)

            return 0

        return sorted(resources, key=cmp_to_key(sorter))