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))