code: def sort_resources(cls, request, resources, fail_enum, header_proto=None):
          
          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))
docs: 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